projection

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextKeyJobName = ContextKey("name")
	ContextKeyId      = ContextKey("id")
	ContextKeyRunId   = ContextKey("run-id")
)
View Source
var (
	ErrNotFound = errors.New("projection not found")
)

Functions

func Deduplicate added in v0.0.28

func Deduplicate[T comparable](in <-chan T, window time.Duration) <-chan T

func Filter added in v0.0.28

func Filter[T ProgressAwareTarget](t T, evts []event.Event) ([]event.Event, error)

func PeriodicJobTicker added in v0.0.28

func PeriodicJobTicker(ctx context.Context, d time.Duration, s projection.Schedule, opts ...query.Option) <-chan error

func PeriodicJobTickerFunc added in v0.0.39

func PeriodicJobTickerFunc(ctx context.Context, d time.Duration, s projection.Schedule, tickFn func(context.Context) ([]query.Option, error), opts ...query.Option) <-chan error

func Use added in v0.0.28

func Use[T ProgressAwareTarget](
	j projection.Job,
	newFn func(context.Context) (T, error),
	getFn func(context.Context, string) (T, error),
	saveFn func(context.Context, T) error,
	useFn func(context.Context, T) error) error

Types

type ContextKey added in v0.0.3

type ContextKey string

type Group added in v0.0.28

type Group[K comparable, V any] struct {
	Key   K
	Value []V
}

func GroupByFunc added in v0.0.28

func GroupByFunc[K comparable, V any](ctx context.Context, groupFn func(V) (K, error), in <-chan V, errs ...<-chan error) ([]Group[K, V], error)

type Groups added in v0.0.33

type Groups[K comparable, V any] []Group[K, V]

func (Groups[K, V]) Keys added in v0.0.33

func (g Groups[K, V]) Keys() []K

func (Groups[K, V]) Map added in v0.0.33

func (g Groups[K, V]) Map() map[K]Group[K, V]

type ProgressAwareTarget added in v0.0.28

type ProgressAwareTarget interface {
	ApplyEvent(event.Event)
	Progress() (time.Time, []uuid.UUID)
	Key() string
	Dirty() bool
}

type ProjectionProgressor added in v0.0.28

type ProjectionProgressor struct {
	*projection.Progressor
	// contains filtered or unexported fields
}

func NewProgressor added in v0.0.28

func NewProgressor() *ProjectionProgressor

func (*ProjectionProgressor) Dirty added in v0.0.28

func (p *ProjectionProgressor) Dirty() bool

func (*ProjectionProgressor) SetProgress added in v0.0.28

func (p *ProjectionProgressor) SetProgress(t time.Time, ids ...uuid.UUID)

type Projector

type Projector interface {
	Schedules() Schedules
	HandleJob(projection.Job) error
}

type Registerer

type Registerer interface {
	// RegisterEventHandler registers an event handler for the given event name.
	RegisterEventHandler(eventName string, handler func(event.Event) error)
}

type Scheduler added in v0.0.13

type Scheduler struct {
	Schedule       projection.Schedule
	StartupOptions []projection.SubscribeOption
}

func (*Scheduler) Subscribe added in v0.0.13

func (s *Scheduler) Subscribe(ctx context.Context, handler func(projection.Job) error) (<-chan error, error)

type Schedules

type Schedules = map[string]*Scheduler

type Starter added in v0.0.28

type Starter interface {
	Start(context.Context) error
}

type Worker

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

func New

func New(projector Projector, bus event.Bus, reg *codec.Registry, opts ...WorkerOption) *Worker

func (*Worker) Start

func (svc *Worker) Start(ctx context.Context, opts ...projection.SubscribeOption) (<-chan error, error)

type WorkerOption

type WorkerOption func(*Worker)

func WithErrorFunc added in v0.0.3

func WithErrorFunc(fn func(projection.Job, error)) WorkerOption

func WithLogger

func WithLogger(logger *zap.SugaredLogger) WorkerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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