Documentation ¶
Index ¶
Constants ¶
View Source
const ( EventStatusPending = "pending" EventStatusDequeue = "dequeue" EventStatusRunning = "running" EventStatusCompleted = "completed" EventStatusFailed = "failed" )
Variables ¶
View Source
var ErrEventNotFound = fmt.Errorf("event not found")
Functions ¶
This section is empty.
Types ¶
type ErrEventRunningDelayed ¶
type ErrEventRunningDelayed struct {
// contains filtered or unexported fields
}
ErrEventRunningDelayed stand for long-run event that need to delay add back.
func NewErrEventRunningDelayed ¶
func NewErrEventRunningDelayed(message string, delay time.Duration) ErrEventRunningDelayed
func (ErrEventRunningDelayed) Delay ¶
func (e ErrEventRunningDelayed) Delay() time.Duration
func (ErrEventRunningDelayed) Error ¶
func (e ErrEventRunningDelayed) Error() string
type EventBus ¶
type EventBus interface { Publish(ctx context.Context, event IEvent) error Subscribe(eventType string, handler EventHandler) Start(ctx context.Context, workers int) error Close(ctx context.Context) error }
EventBus stands for event bus.
func NewEventBus ¶
func NewEventBus(repository EventRepository, options ...Option) (EventBus, error)
NewEventBus new an event bus.
type EventHandler ¶
EventHandler represents a function that handle a event
type EventHandlerFunc ¶
type EventRepository ¶
type EventRepository interface { Get(ctx context.Context, id string) (*Event, error) Save(ctx context.Context, event *Event) error ListAndLockUnfinishedEvents(ctx context.Context, limit int, eventTypes []string) ([]*Event, error) UpdateStatus(ctx context.Context, event *Event, status string) error UpdateRetryCount(ctx context.Context, event *Event, retryCount int) error Search(ctx context.Context, filter *Filter) ([]*Event, error) }
type Impl ¶
Impl implement event bus
func (*Impl) Subscribe ¶
func (engine *Impl) Subscribe(eventType string, handler EventHandler)
Subscribe register a handler for the event type.
type Option ¶
type Option func(impl *Impl)
Option options of impl
func WithSyncPeriod ¶
WithSyncPeriod set sync period
Click to show internal directories.
Click to hide internal directories.