eventbus

package
v2.24.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrFunc

type ErrFunc func(err error)

ErrFunc used by handler to report error from observation

type Event

type Event = interface {
	Version() uint64
	EventType() string
	AggregateID() string
	GroupID() string
	IsSnapshot() bool
	Timestamp() time.Time
	ETag() *eventstore.ETagData
	ServiceID() (string, bool)
	Types() []string
}

Event interface over event created by user.

type EventUnmarshaler

type EventUnmarshaler = interface {
	Version() uint64
	EventType() string
	AggregateID() string
	GroupID() string
	IsSnapshot() bool
	Timestamp() time.Time
	Unmarshal(v interface{}) error
}

EventUnmarshaler provides event.

type GoroutinePoolGoFunc

type GoroutinePoolGoFunc func(func()) error

GoroutinePoolGoFunc processes actions via provided function

type GoroutinePoolHandler

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

GoroutinePoolHandler submit events to goroutine pool for process them.

func NewGoroutinePoolHandler

func NewGoroutinePoolHandler(
	goroutinePoolGo GoroutinePoolGoFunc,
	eventsHandler Handler,
	errFunc ErrFunc,
) *GoroutinePoolHandler

NewGoroutinePoolHandler creates new event processor.

func (*GoroutinePoolHandler) Handle

func (ep *GoroutinePoolHandler) Handle(ctx context.Context, iter Iter) (err error)

Handle pushes event to queue and process the queue by goroutine pool.

type Handler

type Handler = interface {
	Handle(ctx context.Context, iter Iter) (err error)
}

Handler provides handler for eventstore or eventbus.

type Iter

type Iter = interface {
	Next(ctx context.Context) (EventUnmarshaler, bool)
	Err() error
}

Iter provides iterator over events from eventstore or eventbus.

type Observer

type Observer interface {
	Close() error
	SetTopics(ctx context.Context, topics []string) error
}

Observer handles events from observation and forward them to EventHandler.

type Publisher

type Publisher interface {
	Publish(ctx context.Context, topics []string, groupID, aggregateID string, event Event) error
	GetPublishSubject(owner string, event Event) []string
}

Publisher publish event to topics

type Subscriber

type Subscriber interface {
	Subscribe(ctx context.Context, subscriptionID string, topics []string, eh Handler) (Observer, error)
	GetResourceEventSubjects(owner string, resourceID *commands.ResourceId, eventType string) []string
}

Subscriber creates observation over topics. When subscriptionID is same among more Subscribers events are balanced among them.

Directories

Path Synopsis
nats

Jump to

Keyboard shortcuts

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