package events
import "github.com/gobuffalo/events"
Index ¶
- Constants
- func Emit(e Event) error
- func EmitError(kind string, err error, payload interface{}) error
- func EmitPayload(kind string, payload interface{}) error
- func List() ([]string, error)
- func LoadPlugins() error
- func SetManager(m Manager)
- type DeleteFn
- func Listen(l Listener) (DeleteFn, error)
- func NamedListen(name string, l Listener) (DeleteFn, error)
- type Event
- func (e Event) IsError() bool
- func (e Event) MarshalJSON() ([]byte, error)
- func (e Event) String() string
- func (e Event) Validate() error
- type Listener
- type Manager
- type Payload
Constants ¶
const ( // ErrGeneral is emitted for general errors ErrGeneral = "general:err" // ErrPanic is emitted when a panic is recovered ErrPanic = "panic:err" )
const Version = "v1.4.0"
Functions ¶
func Emit ¶
Emit an event to all listeners
func EmitError ¶
func EmitPayload ¶
func List ¶
List all listeners
func LoadPlugins ¶
func LoadPlugins() error
LoadPlugins will add listeners for any plugins that support "events"
func SetManager ¶
func SetManager(m Manager)
SetManager allows you to replace the default event manager with a custom one
Types ¶
type DeleteFn ¶
type DeleteFn func()
func Listen ¶
Listen for events.
func NamedListen ¶
NamedListen for events. Name is the name of the listener NOT the events you want to listen for, so something like "my-listener", "kafka-listener", etc...
type Event ¶
type Event struct { // Kind is the "type" of event "app:start" Kind string `json:"kind"` // Message is optional Message string `json:"message"` // Payload is optional Payload Payload `json:"payload"` // Error is optional Error error `json:"-"` }
Event represents different events in the lifecycle of a Buffalo app
func (Event) IsError ¶
func (Event) MarshalJSON ¶
MarshalJSON implements the json marshaler for an event
func (Event) String ¶
func (Event) Validate ¶
Validate that an event is ready to be emitted
type Listener ¶
type Listener func(e Event)
Listener is a function capable of handling events
func Filter ¶
Filter compiles the string as a regex and returns the original listener wrapped in a new listener that filters incoming events by the Kind
type Manager ¶
Manager can be implemented to replace the default events manager
func DefaultManager ¶
func DefaultManager() Manager
DefaultManager implements a map backed Manager
type Payload ¶
Source Files ¶
event.go events.go filter.go listener.go listener_map.go manager.go plugins.go version.go
Directories ¶
Path | Synopsis |
---|---|
internal |
- Version
- v1.4.3 (latest)
- Published
- Jul 6, 2022
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 2 weeks ago –
Tools for package owners.