projection

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(context.Context, messages.Message) error

Handler should handle the event provided.

type HasProjectionManager

type HasProjectionManager interface {
	GetProjectionManager() Manager
}

HasProjectionManager should be implemented by an event store that can return a projection manager. We have decided to not put this in the event store package to keep is separated, however your event store implementation should have one.

type Manager

type Manager interface {
	// Create a new stream.
	Create(ctx context.Context, name string, options []ProjectorOpt) (Projector, error)

	// Delete will remove the projection from the projections store.
	Delete(ctx context.Context, projectionName string) error

	// Reset will reset the position of the stream to 0.
	Reset(ctx context.Context, projectionName string) error

	// Stop will set the status to stop, the running projection should handle this.
	Stop(ctx context.Context, projectionName string) error

	// FetchProjections grabs projections matching the filter.
	FetchProjectionNames(ctx context.Context, filter string, start, limit uint64) ([]string, error)

	// FetchPojectionStatus will return the status of a projection.
	FetchPojectionStatus(ctx context.Context, projectionName string) (Status, error)

	// FetchPojectionStreamPositions will return the status of a projection.
	FetchPojectionStreamPositions(ctx context.Context, projectionName string) (StreamPositions, error)
}

Manager manages projections.

type Projector

type Projector interface {
	// FromStream will limit the Projector to events from 1 stream.
	FromStream(streamName string) Projector
	// FromStreams will limit the Projector to events from many streams.
	FromStreams(streamNames []string) Projector
	// When the event with the event name is given the Handler will be called.
	When(eventName string, cb Handler) Projector
	// WhenAny event is given the Handler will be called.
	WhenAny(cb Handler) Projector
	// Stop will stop the processing of the events.
	Stop(ctx context.Context) error
	// Run will start the processing of the events.
	Run(ctx context.Context) error
}

Projector describes what should be possible by an implementor.

type ProjectorOpt

type ProjectorOpt func(*ProjectorOpts) error

ProjectorOpt applies configuration to projector options.

func WithSleep

func WithSleep(v time.Duration) ProjectorOpt

WithSleep will set the Sleep on the projector options.

type ProjectorOpts

type ProjectorOpts struct {
	// Sleep how long after reading all the events should we sleep before reading more.
	Sleep time.Duration
}

ProjectorOpts contains options for the projector.

func BuildOptionsFrom

func BuildOptionsFrom(opts []ProjectorOpt) (*ProjectorOpts, error)

BuildOptionsFrom ...

type Status

type Status string

Status of the projection.

const (
	// StatusRunning is set when the projector is running.
	StatusRunning Status = "running"
	// StatusStopping is set when the projector is stopping.
	StatusStopping Status = "stopping"
	// StatusDeleting is set when the projector is deleting.
	StatusDeleting Status = "deleting"
	// StatusResetting is set when the projector is resetting.
	StatusResetting Status = "resetting"
	// StatusIdle is set when the projector is idle.
	StatusIdle Status = "idle"
)

type StreamPositions

type StreamPositions map[string]uint64

StreamPositions provides the stream name and current position in the projection.

Jump to

Keyboard shortcuts

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