Documentation ¶
Overview ¶
package timings provides an interface and methods for background timing monitors
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMonitor ¶ added in v1.0.0
func RegisterMonitor(ctx context.Context, scheme string, init_func MonitorInitializationFunc) error
RegisterMonitor registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Monitor` instances by the `NewMonitor` method.
Types ¶
type CounterMonitor ¶
type CounterMonitor struct { Monitor // contains filtered or unexported fields }
type CounterMonitor implements the `Monitor` interface providing a background timings mechanism that tracks incrementing events.
func (*CounterMonitor) Signal ¶
func (t *CounterMonitor) Signal(ctx context.Context, args ...interface{}) error
Signal will cause the background monitors counter to be incremented by one.
type Monitor ¶
type Monitor interface { // The Start method starts the monitor dispatching notifications to an io.Writer instance Start(context.Context, io.Writer) error // The Stop method will stop monitoring Stop(context.Context) error // The Signal method will dispatch messages to the monitoring process Signal(context.Context, ...interface{}) error }
type Monitor provides a common interface for timings-based monitors
func NewCounterMonitor ¶
NewCounterMonitor creates a new `CounterMonitor` instance that will dispatch notifications using a time.Ticker configured by 'uri' which is expected to take the form of:
counter://?duration={ISO8601_DURATION}
Where {ISO8601_DURATION} is a valid ISO8601 duration string.
func NewMonitor ¶ added in v1.0.0
NewMonitor returns a new `Monitor` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `MonitorInitializationFunc` function used to instantiate the new `Monitor`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterMonitor` method.
func NewNullMonitor ¶ added in v1.0.0
NewNullMonitor() creates a new `NullMonitor` which does nothing.
null://
type MonitorInitializationFunc ¶ added in v1.0.0
MonitorInitializationFunc is a function defined by individual monitor package and used to create an instance of that monitor
type NullMonitor ¶ added in v1.0.0
type NullMonitor struct {
Monitor
}
type NullMonitor implements the `Monitor` interface but does nothing.
func (*NullMonitor) Signal ¶ added in v1.0.0
func (nm *NullMonitor) Signal(ctx context.Context, args ...interface{}) error
Signal() is a no-op and nothing will happen.
type SinceEvent ¶ added in v1.2.0
type SinceEvent uint8
const ( SinceStart SinceEvent = iota SinceStop )
type SinceMonitor ¶ added in v1.1.0
type SinceMonitor struct { Monitor // contains filtered or unexported fields }
type SinceMonitor implements the `Monitor` interface providing a background timings mechanism that tracks the duration of time between events.
func (*SinceMonitor) Signal ¶ added in v1.1.0
func (t *SinceMonitor) Signal(ctx context.Context, args ...interface{}) error
Signal will cause the background monitors since to be incremented by one.
type SinceResponse ¶ added in v1.1.0
type SinceResponse struct { // Label is a string that was included with a `Signal` event Label string `json:"message"` // Duration is the string representation of a `time.Duuration` which is the amount of time that elapsed between `Signal` events Duration string `json:"duration"` // Timestamp is the Unix timestamp when the `SinceResponse` was created Timestamp int64 `json:"timestamp"` }
SinceResponse is a struct containing information related to a "since" timing event.
func (SinceResponse) String ¶ added in v1.2.1
func (s SinceResponse) String() string
String() returns a string representation of the response.