mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 21:15:56 +00:00
publish v12.2.0-alpha6
This commit is contained in:
33
middleware/monitor/expvar_uint64.go
Normal file
33
middleware/monitor/expvar_uint64.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package monitor
|
||||
|
||||
import (
|
||||
"expvar"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Uint64 completes the expvar metric interface, holds an uint64 value.
|
||||
type Uint64 struct {
|
||||
value uint64
|
||||
}
|
||||
|
||||
// Set sets v to value.
|
||||
func (v *Uint64) Set(value uint64) {
|
||||
atomic.StoreUint64(&v.value, value)
|
||||
}
|
||||
|
||||
// Value returns the underline uint64 value.
|
||||
func (v *Uint64) Value() uint64 {
|
||||
return atomic.LoadUint64(&v.value)
|
||||
}
|
||||
|
||||
// String returns the text representation of the underline uint64 value.
|
||||
func (v *Uint64) String() string {
|
||||
return strconv.FormatUint(atomic.LoadUint64(&v.value), 10)
|
||||
}
|
||||
|
||||
func newUint64(name string) *Uint64 {
|
||||
v := new(Uint64)
|
||||
expvar.Publish(name, v)
|
||||
return v
|
||||
}
|
||||
Reference in New Issue
Block a user