Help us shape the future of Go! Take the 2026 Go Developer Survey

emitter

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package emitter owns the event channel: it filters, counts dropped events, and guarantees the done event is sent once and waited for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter struct {
	// contains filtered or unexported fields
}

func New

func New(opts Options, sink Sink, iterations Iterations, results Results, logger *slog.Logger) *Emitter

func (*Emitter) Close

func (e *Emitter) Close()

Close closes the channel. Events emitted afterwards are discarded.

func (*Emitter) Done

func (e *Emitter) Done(d event.DoneData)

Done records the outcome and sends the done event. Only the first call has any effect, so a run has exactly one outcome. Unlike Emit, a full channel does not drop it: the send waits for a reader for up to DoneGrace.

func (*Emitter) Dropped

func (e *Emitter) Dropped() int

Dropped counts events dropped because the channel was full.

func (*Emitter) Emit

func (e *Emitter) Emit(data event.Data)

Emit offers an intermediate event. When the channel is full the event is dropped and counted.

func (*Emitter) Events

func (e *Emitter) Events() <-chan event.Event

Events is the channel the caller reads. Close closes it.

type Iterations

type Iterations interface {
	Iteration() int
}

Iterations says which iteration an event belongs to. → state.Run

type Options

type Options struct {
	Buffer       int
	StreamEvents bool          // false: only Error and Done events are emitted
	DoneGrace    time.Duration // how long Done waits for a reader when the channel is full
}

Options are the emitter's fixed settings.

type Results

type Results interface {
	SetResult(d event.DoneData)
}

Results records the run's outcome before the done event is sent. → state.Run

type Sink

type Sink interface {
	Write(evt event.Event)
}

Sink receives every event, synchronously, before it is offered to the channel. → the caller's loop.EventSink, or defaults.NoSink

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL