Documentation ¶
Overview ¶
Package events provides functionalities for packages to log their states as events for others to consume and display to end users in meaningful ways.
Index ¶
- Constants
- type Bus
- func (b Bus) Events() <-chan Event
- func (b Bus) Send(message string, options ...Option)
- func (b Bus) SendError(err error, options ...Option)
- func (b Bus) SendInfo(message string, options ...Option)
- func (b Bus) SendView(s fmt.Stringer, options ...Option)
- func (b Bus) Sendf(format string, a ...any)
- func (b *Bus) Stop()
- type BusOption
- type Event
- type Option
- type ProgressIndication
- type Provider
Constants ¶
const DefaultBufferSize = 50
DefaultBufferSize defines the default maximum number of events that the bus can cache before they are handled.
const (
GroupError = "error"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus defines a bus to send and receive events.
func (Bus) Send ¶
Send sends a new event to bus. This method will block if the event bus buffer is full.
func (Bus) SendView ¶ added in v0.25.0
SendView sends a new event for a view to the bus. Views are types that implement the `fmt.Stringer` interface which allow events with complex message formats.
type BusOption ¶
type BusOption func(*Bus)
BusOption configures the Bus.
func WithBufferSize ¶ added in v0.25.0
WithBufferSize assigns the size of the buffer to use for buffering events.
type Event ¶
type Event struct { ProgressIndication ProgressIndication Icon string Message string Verbose bool Group string }
Event represents a state.
func (Event) InProgress ¶ added in v0.25.0
InProgress returns true when the event is in progress.
type Option ¶
type Option func(*Event)
Option event options.
func ProgressFinish ¶ added in v0.26.0
func ProgressFinish() Option
ProgressFinish indicates that a status event finished the ongoing task.
func ProgressStart ¶ added in v0.26.0
func ProgressStart() Option
ProgressStart indicates that a status event starts the progress indicator.
func ProgressUpdate ¶ added in v0.26.0
func ProgressUpdate() Option
ProgressUpdate indicates that a status event updated the current progress.
type ProgressIndication ¶ added in v0.25.0
type ProgressIndication uint8
ProgressIndication enumerates possible states of progress indication for an Event.
const ( IndicationNone ProgressIndication = iota IndicationStart IndicationUpdate IndicationFinish )