event

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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