Documentation
¶
Index ¶
- func FindOperation[T any, O interface{ ... }](ctx context.Context) (*T, bool)
- func FinishOperation[O Operation, E ResultOf[O]](op O, results E)
- func InitRootOperation(op Operation)
- func IsRootOperationInitialized() bool
- func OnFinish[O Operation, E ResultOf[O]](op Operation, l EventListener[O, E])
- func OnStart[O Operation, E ArgOf[O]](op Operation, l EventListener[O, E])
- func RegisterOperation(ctx context.Context, op Operation) context.Context
- func StartAndRegisterOperation[O Operation, E ArgOf[O]](ctx context.Context, op O, args E) context.Context
- func StartOperation[O Operation, E ArgOf[O]](op O, args E)
- type ArgOf
- type EventListener
- type Operation
- type ResultOf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindOperation ¶
FindOperation returns the Operation of T if the context has the Operation of T. This is used to identify the relationship between application processes.
func FinishOperation ¶
FinishOperation finishes the operation. This function notifies the event listeners of the operation and the parent operation.
func InitRootOperation ¶
func InitRootOperation(op Operation)
InitRootOperation initializes the root operation. The root operation should be passed to op created by NewRootOperation.
func IsRootOperationInitialized ¶
func IsRootOperationInitialized() bool
func OnFinish ¶
func OnFinish[O Operation, E ResultOf[O]](op Operation, l EventListener[O, E])
OnFinish registers the event listener to the operation.
func OnStart ¶
func OnStart[O Operation, E ArgOf[O]](op Operation, l EventListener[O, E])
On registers the event listener to the operation.
func RegisterOperation ¶
RegisterOperation registers the operation to the context.
func StartAndRegisterOperation ¶
func StartAndRegisterOperation[O Operation, E ArgOf[O]](ctx context.Context, op O, args E) context.Context
StartAndRegisterOperation starts the operation and registers the operation to the context.
func StartOperation ¶
StartOperation starts the operation. This function notifies the event listeners of the parent operation.
Types ¶
type ArgOf ¶
type ArgOf[O Operation] interface { IsArgOf(O) }
IsArgOf is a marker interface that marks the type as an argument of the operation.
type EventListener ¶
EventListener is a function type that is called when an event is emitted. At the start and end of the Operation, you can execute func(O, T)
type Operation ¶
type Operation interface { // GetRootID returns the root operation ID. GetRootID() string // GetID returns the operation ID. GetID() string // Parent returns the parent operation. Parent() Operation // contains filtered or unexported methods }
Operation is the interface that wraps the basic operation methods. An operation is a unit of application process (e.g. HTTP Request handling, Execute SQL Query, etc...) that can be started and finished. When an operation is started or finished, events are notified to event listeners.
func FindOperationFromContext ¶
FindOperationFromContext returns the operation from the context. This is used to share operations between application processes such as executing SQL queries and sending HTTP requests.
func NewOperation ¶
NewOperation creates a new operation.
func NewRootOperation ¶
func NewRootOperation() Operation
NewRootOperation creates a new root operation.