Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventListener ¶
type EventListener interface { // ListenedType returns the Go type the event listener listens to. ListenedType() reflect.Type // Call the underlying event listener function. The type of the value v // is the type the event listener listens to, according to the type // returned by ListenedType(). Call(op Operation, v interface{}) }
EventListener interface allowing to identify the Go type listened to and dispatch calls to the underlying event listener function.
type Operation ¶
type Operation interface { // On allows to register an event listener to the operation. The event // listener will be removed from the operation once it finishes. On(EventListener) // Parent return the parent operation. It returns nil for the root // operation. Parent() Operation // contains filtered or unexported methods }
Operation interface type allowing to register event listeners to the operation. The event listeners will be automatically removed from the operation once it finishes so that it no longer can be called on finished operations.
type OperationImpl ¶
type OperationImpl struct {
// contains filtered or unexported fields
}
OperationImpl structure allowing to subscribe to operation events and to navigate in the operation stack. Events bubble-up the operation stack, which allows listening to future events that might happen in the operation lifetime.
func StartOperation ¶
func StartOperation(args interface{}, parent Operation) *OperationImpl
StartOperation starts a new operation along with its arguments and emits a start event with the operation arguments.
func (*OperationImpl) Finish ¶
func (o *OperationImpl) Finish(results interface{})
Finish finishes the operation along with its results and emits a finish event with the operation results. The operation is then disabled and its event listeners removed.
func (*OperationImpl) On ¶
func (o *OperationImpl) On(l EventListener)
On registers the event listener. The difference with the Register() is that it doesn't return a function closure, which avoids unnecessary allocations For example:
op.On(HTTPHandlerOperationStart(func (op *OperationImpl, args HTTPHandlerOperationArgs) { // ... }))
func (*OperationImpl) Parent ¶
func (o *OperationImpl) Parent() Operation
Parent return the parent operation. It returns nil for the root operation.
type UnregisterFunc ¶
type UnregisterFunc func()
UnregisterFunc is a function allowing to unregister from an operation the previously registered event listeners.
func Register ¶
func Register(listeners ...EventListener) UnregisterFunc
Register global operation event listeners to listen to.