Documentation ¶
Overview ¶
Package event contains the event system used to notify external components of various internal events during test execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Event ¶
Event is the emitted object sent to all subscribers of its type. The subscriber should call its Done method when finished processing to notify the emitter, though this is not required for all events.
type ExitData ¶
type ExitData struct {
Error error
}
ExitData is the data sent in the Exit event. Error is the error returned by the run command.
type Subscriber ¶
type Subscriber interface { Subscribe(events ...Type) (subID uint64, eventsCh <-chan *Event) Unsubscribe(subID uint64) }
Subscriber is a limited interface of System that only allows subscribing and unsubscribing.
type System ¶
type System struct {
// contains filtered or unexported fields
}
System keeps track of subscribers, and allows subscribing to and emitting events.
func NewEventSystem ¶
func NewEventSystem(eventBuffer int, logger logrus.FieldLogger) *System
NewEventSystem returns a new System. eventBuffer determines the size of the Event channel buffer. Events might be dropped if this buffer is full and there are no event listeners, or if events are emitted very quickly and the event handler goroutine is busy. It is recommended to handle events in a separate goroutine to not block the listener goroutine.
func (*System) Emit ¶
Emit the event to all subscribers of its type. It returns a function that can be optionally used to wait for all subscribers to process the event (by signalling via the Done method).
func (*System) Subscribe ¶
Subscribe to one or more events. It returns a subscriber ID that can be used to unsubscribe, and an Event channel to receive events. It panics if events is empty.
func (*System) Unsubscribe ¶
Unsubscribe closes the Event channel and removes the subscription with ID subID.
func (*System) UnsubscribeAll ¶
func (s *System) UnsubscribeAll()
UnsubscribeAll closes all event channels and removes all subscriptions.
type Type ¶
type Type uint8
Type represents the different event types emitted by k6.
const ( // Init is emitted when k6 starts initializing outputs, VUs and executors. Init Type = iota + 1 // TestStart is emitted when the execution scheduler starts running the test. TestStart // TestEnd is emitted when the test execution ends. TestEnd // IterStart is emitted when a VU starts an iteration. IterStart // IterEnd is emitted when a VU ends an iteration. IterEnd // Exit is emitted when the k6 process is about to exit. Exit )
func TypeString ¶
TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.