Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteSubscription(ctx context.Context, client *pubsub.Client, name string) error
- func FromContextAny(ctx context.Context, key string) interface{}
- func GetOrCreateSubscription(ctx context.Context, client *pubsub.Client, name string, topic *pubsub.Topic) (*pubsub.Subscription, error)
- func GetOrCreateTopic(ctx context.Context, client *pubsub.Client, topic string) (*pubsub.Topic, error)
- func IsSnapshotTime(e *pb.Event, factor int64) bool
- func NewEventSourceCommandClient(target string) *plutoClt.Client
- func NewEventSourceQueryClient(target string) *plutoClt.Client
- func Subscribe(client *pubsub.Client, name string, topics Topics) pluto.HookFunc
- func TakeSnapshot(ctx context.Context, e *pb.Event, aggregator proto.Message, aFn ApplyFn) error
- func UnmarshalEventData(e *pb.Event, out interface{}) error
- func UpdateTopic(ctx context.Context, t *pubsub.Topic) (pubsub.TopicConfig, error)
- func WithContextAny(ctx context.Context, key string, val interface{}) context.Context
- type Action
- type ApplyFn
- type HookFn
- type Store
- type Topics
- type Validate
Constants ¶
const ( // EventSourceQueryClientName constant to be used as name of the event source query client connection EventSourceQueryClientName string = "event_source_query" // EventSourceCommandClientName constant to be used as name of the event source command client connection EventSourceCommandClientName string = "event_source_command" // AggregatorIDQueryKey constant to be used as the key in Query Params AggregatorIDQueryKey string = "AID" // HighestVersionQueryKey constant to be used as the key in Query Params HighestVersionQueryKey string = "HV" // LowestVersionQueryKey constant to be used as the key in Query Params LowestVersionQueryKey string = "LV" )
const (
// SnapshotCreated topic
SnapshotCreated = "snapshot_created"
)
Variables ¶
var ( ErrEventWithoutAggregate = errors.New("event can not contain nil as aggregate") ErrInvalidAggregateId = errors.New("event can not have an empty string as aggregateID") ErrInvalidVersion = errors.New("event can not have 0 as version") )
var ErrConcurrencyException = status.Error(codes.Aborted, "concurrency exception")
Functions ¶
func DeleteSubscription ¶
DeleteSubscription deletes a Cloud PubSub subscription
func FromContextAny ¶
FromContextAny returns from context the interface value to which the key is associated.
func GetOrCreateSubscription ¶
func GetOrCreateSubscription(ctx context.Context, client *pubsub.Client, name string, topic *pubsub.Topic) (*pubsub.Subscription, error)
GetOrCreateSubscription gets a reference or creates a Cloud PubSub subscription for the input topic
func GetOrCreateTopic ¶
func GetOrCreateTopic(ctx context.Context, client *pubsub.Client, topic string) (*pubsub.Topic, error)
GetOrCreateTopic create a Cloud PubSub topic if not exists
func IsSnapshotTime ¶
IsSnapshotTime validate if event version is valid to be used as snapshot based on input factor
func NewEventSourceCommandClient ¶
NewEventSourceCommandClient wrapper for a event source command grpc pluto client
func NewEventSourceQueryClient ¶
NewEventSourceQueryClient wrapper for a event source query grpc pluto client
func TakeSnapshot ¶
TakeSnapshot loads an agregator up to current state and triggers a snapshot
func UnmarshalEventData ¶
UnmarshalEventData gets the unserialized data from the event
func UpdateTopic ¶
UpdateTopic updates topic environment labels
Types ¶
type Action ¶
Action signature of a action func
func ActionWrapper ¶
ActionWrapper loads an agregator current state and previous. Hook functions should be used to trigger any subsequent business rules Or just simple cache the state of the aggregator
type Store ¶
Store holds aggregator state and version
func Aggregate ¶
func Aggregate(ctx context.Context, aggregator interface{}, id string, in proto.Message, topic string, metadata map[string]string, apply ApplyFn, validations ...Validate) (*Store, error)
Aggregate proceess all aggregate steps
func (*Store) LoadEvents ¶
LoadEvents stream events by aggregator id and apply the required changes TODO: use snapshots