event

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provider

func Provider(handler func(resolver infra.Resolver, listener Listener), options ...Option) infra.Provider

Provider create a event Provider

Types

type AsyncEvent

type AsyncEvent interface {
	Async() bool
}

type Event

type Event struct {
	Name  string
	Event interface{}
}

type Listener

type Listener interface {
	Listen(listeners ...interface{})
}

type Manager

type Manager interface {
	Publisher
	Listener
	Call(evt interface{}, listener interface{})
	Start(ctx context.Context) <-chan interface{}
}

func NewEventManager

func NewEventManager(store Store) Manager

NewEventManager create a eventManager

type MemoryEventStore

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

MemoryEventStore is a event store for sync operations

func (*MemoryEventStore) Listen

func (eventStore *MemoryEventStore) Listen(evtType string, listener interface{})

Listen add a listener to a event

func (*MemoryEventStore) Publish

func (eventStore *MemoryEventStore) Publish(evt Event) error

Publish an event

func (*MemoryEventStore) SetManager

func (eventStore *MemoryEventStore) SetManager(manager Manager)

SetManager event manager

func (*MemoryEventStore) Start

func (eventStore *MemoryEventStore) Start(ctx context.Context) <-chan interface{}

type Option

type Option func(p *provider)

func SetStoreOption

func SetStoreOption(h func(cc infra.Resolver) Store) Option

SetStoreOption 设置底层存储实现

type Publisher

type Publisher interface {
	Publish(evt interface{}) error
}

type Store

type Store interface {
	Listen(eventName string, listener interface{})
	Publish(evt Event) error
	SetManager(manager Manager)
	Start(ctx context.Context) <-chan interface{}
}

Store is an interface for event store

func NewMemoryEventStore

func NewMemoryEventStore(async bool, capacity int) Store

NewMemoryEventStore create a sync event store

Jump to

Keyboard shortcuts

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