Documentation ¶
Overview ¶
Package stayset helps counting executions and/or instances and getting aware of minimum and maximum parallel instances.
Individual stay-set indicators can be created via New and a namespace. They are automatically registered at a backend for the global retrieval. The indicators got individual identifiers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the http.Handler.
func NewHandler ¶
NewHandler returns an instance of a web handler for the stopwatch.
type Indication ¶
type Indication struct {
// contains filtered or unexported fields
}
Indication contains one current indication point.
type IndicatorPoint ¶
type IndicatorPoint struct {
// contains filtered or unexported fields
}
IndicatorPoint collects the countings of one code section.
func (*IndicatorPoint) Measure ¶
func (ip *IndicatorPoint) Measure(f func())
Measure is a convenience function to measure one anonymous function.
func (*IndicatorPoint) Start ¶
func (ip *IndicatorPoint) Start() Indication
Start begins a new measurement.
func (*IndicatorPoint) Value ¶
func (ip *IndicatorPoint) Value() IndicatorPointValue
Value returns the current value.
type IndicatorPointValue ¶
type IndicatorPointValue struct { Namespace string `json:"namespace"` ID string `json:"id"` Quantity int `json:"quantity"` Current int `json:"current"` Minimum int `json:"minimum"` Maximum int `json:"maximum"` }
IndicatorPointValue contains the accumulated value of one indicator point.
func (IndicatorPointValue) String ¶
func (ipv IndicatorPointValue) String() string
String implements the fmt.Stringer interface.
type IndicatorPointValues ¶
type IndicatorPointValues []IndicatorPointValue
IndicatorPointValues contains a set of accumulated indicator point values.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the register type for a number of SSIs.
func FromContext ¶
FromContext retrieves a Registry from a context.
func (*Registry) ForNamespace ¶
ForNamespace creates an instance of a SSI with the given namespace. In case that namespace is already in use that SSI will be returned.
func (*Registry) Values ¶
func (r *Registry) Values() IndicatorPointValues
Values returns the values of all metering points.
type SSI ¶
type SSI struct {
// contains filtered or unexported fields
}
SSI allows to measure the execution numbers at multiple counting points in one namespace.
func (*SSI) IndicatorPoint ¶
func (ssi *SSI) IndicatorPoint(id string) *IndicatorPoint
IndicatorPoint returns a new or already existing indicator point with the given ID.
func (*SSI) IndicatorPointWithValue ¶
func (ssi *SSI) IndicatorPointWithValue(id string, value int) *IndicatorPoint
IndicatorPointWithValue returns a new or already existing indicator point with the given ID and and initial value. In case it's already existing the value isn't changed anymore.
func (*SSI) Values ¶
func (ssi *SSI) Values() IndicatorPointValues
Values returns the accumulated counting point values of this SSI.