Documentation ¶
Overview ¶
Package ops provides a facility for tracking the processing of operations, including contextual metadata about the operation and their final success or failure. An op is assumed to have succeeded if by the time of calling Exit() no errors have been reported. The final status can be reported to a metrics facility.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterReporter ¶
func RegisterReporter(reporter Reporter)
RegisterReporter registers the given reporter.
func SetGlobal ¶
func SetGlobal(key string, value interface{})
SetGlobal puts a key->value pair into the global context, which is inherited by all Ops.
func SetGlobalDynamic ¶
func SetGlobalDynamic(key string, valueFN func() interface{})
SetGlobalDynamic is like SetGlobal but uses a function to derive the value at read time.
Types ¶
type Op ¶
type Op interface { // Begin marks the beginning of an Op under this Op. Begin(name string) Op // Go starts the given function on a new goroutine. Go(fn func()) // End marks the end of this op, at which point the Op will report its success // or failure to all registered Reporters. End() // Set puts a key->value pair into the current Op's context. Set(key string, value interface{}) Op // SetDynamic puts a key->value pair into the current Op's context, where the // value is generated by a function that gets evaluated at every Read. SetDynamic(key string, valueFN func() interface{}) Op // FailIf marks this Op as failed if the given err is not nil. If FailIf is // called multiple times, the latest error will be reported as the failure. // Returns the original error for convenient chaining. FailIf(err error) error }
Op represents an operation that's being performed. It mimics the API of context.Context.
Click to show internal directories.
Click to hide internal directories.