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

event

package
v1.20.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

func NewApplication

func NewApplication(queue contractsqueue.Queue) *Application

func (*Application) Dispatch

func (app *Application) Dispatch(evt any, args ...[]event.Arg) event.Result

Dispatch fires an event and calls all the listeners registered for it, both the ones registered on the event itself and the ones registered on a matching wildcard pattern. Every listener runs, the returned result carries the errors of the ones that failed.

func (*Application) GetEvents deprecated

func (app *Application) GetEvents() map[event.Event][]event.Listener

GetEvents returns a copy of the events registered through Register.

Deprecated: Use Listen instead, GetEvents will be removed in a future version.

func (*Application) Job deprecated

func (app *Application) Job(e event.Event, args []event.Arg) event.Task

Job creates a new event task.

The task now reaches every listener of the event, including the ones registered through Listen and the ones registered on a matching wildcard pattern. It used to look the listeners up by the identity of the event value, so passing a fresh instance only found them for zero size structs.

Deprecated: Use Dispatch instead, Job will be removed in a future version.

func (*Application) Listen

func (app *Application) Listen(events any, listeners ...any) error

Listen registers one or more listeners for one or more events, see event.Instance for the accepted event and listener forms.

func (*Application) Register deprecated

func (app *Application) Register(events map[event.Event][]event.Listener)

Register registers events and their listeners, the listeners are also registered on the Listen flow so that Dispatch can reach them.

Deprecated: Use Listen instead, Register will be removed in a future version.

type Result

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

Result collects the errors returned by the listeners of a single dispatch.

func (*Result) Error

func (r *Result) Error() error

func (*Result) Errors

func (r *Result) Errors() []error

func (*Result) Failed

func (r *Result) Failed() bool

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (r *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (r *ServiceProvider) Register(app foundation.Application)

func (*ServiceProvider) Relationship

func (r *ServiceProvider) Relationship() binding.Relationship

type Task

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

func NewTask

func NewTask(queue contractsqueue.Queue, args []event.Arg, evt event.Event, listeners []event.Listener) *Task

func (*Task) Dispatch

func (receiver *Task) Dispatch() error

Dispatch runs the event through the same pipeline as Dispatch, in the mode that keeps the deprecated behaviour: an unbound event is an error, and the first failing listener stops the ones behind it.

type TestCancelEvent

type TestCancelEvent struct{}

func (*TestCancelEvent) Handle

func (receiver *TestCancelEvent) Handle(args []event.Arg) ([]event.Arg, error)

type TestEvent

type TestEvent struct{}

func (*TestEvent) Handle

func (receiver *TestEvent) Handle(args []event.Arg) ([]event.Arg, error)

type TestEventHandleError

type TestEventHandleError struct{}

func (*TestEventHandleError) Handle

func (receiver *TestEventHandleError) Handle(args []event.Arg) ([]event.Arg, error)

type TestEventNoRegister

type TestEventNoRegister struct{}

func (*TestEventNoRegister) Handle

func (receiver *TestEventNoRegister) Handle(args []event.Arg) ([]event.Arg, error)

type TestListener

type TestListener struct{}

func (*TestListener) Handle

func (receiver *TestListener) Handle(eventName string, args ...any) error

func (*TestListener) Queue

func (receiver *TestListener) Queue(args ...any) event.Queue

func (*TestListener) Signature

func (receiver *TestListener) Signature() string

type TestListenerHandleError

type TestListenerHandleError struct{}

func (*TestListenerHandleError) Handle

func (receiver *TestListenerHandleError) Handle(eventName string, args ...any) error

func (*TestListenerHandleError) Queue

func (receiver *TestListenerHandleError) Queue(args ...any) event.Queue

func (*TestListenerHandleError) Signature

func (receiver *TestListenerHandleError) Signature() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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