guard

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

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

Guard is a projection guard. It is used by the projection system to determine if an event should be applied to a projection.

func New

func New(opts ...Option) *Guard

New returns a new projection guard.

func (*Guard) GuardProjection

func (g *Guard) GuardProjection(evt event.Event) bool

GuardProjection returns true if the given event should be applied to the projection.

type Option

type Option func(*Guard)

Option is a projection guard option.

func Any

func Any(name string, guard func(event.Event) bool) Option

Any returns an Option that specifies the guard for the given event. The projection system will call the guard before applying the given event to a projection and only applies the event if the guard returns true. If the data of an event cannot be casted to the provided type, the event will not be applied.

func Event

func Event[Data any](name string, guard func(event.Of[Data]) bool) Option

Event returns an Option that specifies the guard for the given event. The projection system will call the guard before applying the given event to a projection and only applies the event if the guard returns true. If the data of an event cannot be casted to the provided type, the event will not be applied.

Jump to

Keyboard shortcuts

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