projection

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronJob

type CronJob interface {
	// Unique identity of the cron job.
	Id() string

	// `OnInit()` is called when the cron job first-time initializes. If an error is returned, the system will halt.
	// When you implement `onInit`, make sure all the side effects are idempotent. For example all DB changes should be
	// rollbacked on error.
	OnInit() error

	// Cron Job execution interval in duration
	Interval() time.Duration

	// Execute Cron Job logic on regular interval
	Exec() error
}

A Cron Job is a special type of projection

type Projection

type Projection interface {
	// Unique identity of the projection.
	Id() string

	// Returns an array of event names to listen. All versions of the events will be listened.
	GetEventsToListen() []string

	// Returns the last handled event height. nil mean no event has been handled so far.
	GetLastHandledEventHeight() (*int64, error)

	// `OnInit()` is called when the projection first-time initializes (Before the first event is
	// handled). If an error is returned, the system will attempt to run again on next restart and
	// no event will be handle by this projection until this method return no error.
	// When you implement `onInit`, make sure all the side effects are idempotent. For example all
	// DB changes should be rollbacked on error.
	OnInit() error

	// Handle all events with the same height that matches `GetEventsToListen()` and create
	// projection. It is also responsible to update the last handled event height.
	HandleEvents(height int64, events []entity_event.Event) error
}

Projection interface defines the necessary methods of to create a projection

type StoreBasedManager

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

StoreBasedManager is a projection manager relies on replaying events from EventStore

func NewStoreBasedManager

func NewStoreBasedManager(logger applogger.Logger, eventStore entity_event.Store) *StoreBasedManager

func (*StoreBasedManager) IsProjectionRegistered

func (manager *StoreBasedManager) IsProjectionRegistered(projection Projection) bool

func (*StoreBasedManager) RegisterProjection

func (manager *StoreBasedManager) RegisterProjection(projection Projection) error

func (*StoreBasedManager) RunInBackground

func (manager *StoreBasedManager) RunInBackground()

Starts projectionManager by running all registered projection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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