Documentation ¶
Index ¶
- Variables
- func WithAccessKey(key string) func(*Client)
- func WithBaseURL(rawurl string) func(*Client)
- func WithPollInterval(d time.Duration) func(*Client)
- func WithSecretAccessKey(key string) func(*Client)
- type Action
- type ActionType
- type Aggregate
- type Client
- func (c *Client) AggregateExists(ctx context.Context, aggType, aggID string) (bool, error)
- func (c *Client) AggregatedProjection(ctx context.Context, name string) (*Projection, error)
- func (c *Client) CreateProjectionDefinition(ctx context.Context, d *ProjectionDefinition) error
- func (c *Client) CreateReactionDefinition(ctx context.Context, r *ReactionDefinition) error
- func (c *Client) DeleteProjectionDefinition(ctx context.Context, name string) error
- func (c *Client) DeleteReaction(ctx context.Context, id string) error
- func (c *Client) Feed(ctx context.Context, name string, seq int64, fn func(*FeedEntry)) error
- func (c *Client) FeedSequenceNumber(ctx context.Context, feedName string) (int64, error)
- func (c *Client) Feeds(ctx context.Context) ([]string, error)
- func (c *Client) ListAggregatedProjections(ctx context.Context) ([]*Projection, error)
- func (c *Client) ListProjectionDefinitions(ctx context.Context) ([]*ProjectionDefinition, error)
- func (c *Client) ListReactionDefinitions(ctx context.Context) ([]*ReactionDefinition, error)
- func (c *Client) ListSingleProjections(ctx context.Context, name string) ([]*Projection, error)
- func (c *Client) LoadAggregate(ctx context.Context, aggType, aggID string) (*Aggregate, error)
- func (c *Client) ProjectionDefinition(ctx context.Context, name string) (*ProjectionDefinition, error)
- func (c *Client) ReactionDefinition(ctx context.Context, id string) (*ReactionDefinition, error)
- func (c *Client) SingleProjection(ctx context.Context, projName, aggID string) (*Projection, error)
- func (c *Client) Store(ctx context.Context, aggType, aggID string, version int64, events ...*Event) error
- type Event
- type EventHandler
- type Feed
- type FeedEntry
- type Function
- type Projection
- type ProjectionDefinition
- type ReactionDefinition
Constants ¶
This section is empty.
Variables ¶
var ErrAggregateNotFound = errors.New("aggregate not found")
ErrAggregateNotFound is returned when no events exist for a given aggregate ID.
Functions ¶
func WithAccessKey ¶
WithAccessKey sets the Client access key for authentication.
func WithBaseURL ¶
WithBaseURL sets the Client base URL.
func WithPollInterval ¶
WithPollInterval sets the interval used for polling the API.
func WithSecretAccessKey ¶
WithSecretAccessKey sets the Client secret access key for authentication.
Types ¶
type Action ¶
type Action struct { ActionType ActionType `json:"actionType,omitempty"` TargetURI string `json:"targetUri,omitempty"` Body string `json:"body,omitempty"` }
Action defines a react action.
type ActionType ¶
type ActionType string
ActionType represents a reaction action.
const ( ActionTypeHTTPPost ActionType = "HTTP_POST" ActionTypeSlackPost ActionType = "SLACK_POST" )
Available action types.
type Aggregate ¶
type Aggregate struct { ID string `json:"aggregateId"` Version int `json:"aggregateVersion"` Type string `json:"aggregateType"` Events []*Event `json:"events"` }
Aggregate holds a Serialized.io Aggregate.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the Serialized.io API.
func (*Client) AggregateExists ¶
AggregateExists returns whether a specific aggregate exists.
func (*Client) AggregatedProjection ¶
AggregatedProjection returns an aggregated projection for the given aggregate.
func (*Client) CreateProjectionDefinition ¶
func (c *Client) CreateProjectionDefinition(ctx context.Context, d *ProjectionDefinition) error
CreateProjectionDefinition creates a new reaction definition.
func (*Client) CreateReactionDefinition ¶
func (c *Client) CreateReactionDefinition(ctx context.Context, r *ReactionDefinition) error
CreateReactionDefinition registers a new reaction definition.
func (*Client) DeleteProjectionDefinition ¶
DeleteProjectionDefinition deletes a projection definition.
func (*Client) DeleteReaction ¶
DeleteReaction deletes a reaction with a given ID.
func (*Client) Feed ¶
Feed runs the given function for every feed entry. This call blocks until the provided context is cancelled.
func (*Client) FeedSequenceNumber ¶
FeedSequenceNumber returns current sequence number at head for a given feed.
func (*Client) ListAggregatedProjections ¶
func (c *Client) ListAggregatedProjections(ctx context.Context) ([]*Projection, error)
ListAggregatedProjections lists all single projections.
func (*Client) ListProjectionDefinitions ¶
func (c *Client) ListProjectionDefinitions(ctx context.Context) ([]*ProjectionDefinition, error)
ListProjectionDefinitions lists all definitions.
func (*Client) ListReactionDefinitions ¶
func (c *Client) ListReactionDefinitions(ctx context.Context) ([]*ReactionDefinition, error)
ListReactionDefinitions returns all registered reactions.
func (*Client) ListSingleProjections ¶
ListSingleProjections lists all single projections.
func (*Client) LoadAggregate ¶
LoadAggregate loads all events for a single aggregate.
func (*Client) ProjectionDefinition ¶
func (c *Client) ProjectionDefinition(ctx context.Context, name string) (*ProjectionDefinition, error)
ProjectionDefinition returns a projection definition by name.
func (*Client) ReactionDefinition ¶
ReactionDefinition returns a reaction definition with a given ID.
func (*Client) SingleProjection ¶
SingleProjection returns a single projection for the given aggregate.
type Event ¶
type Event struct { ID string `json:"eventId"` Type string `json:"eventType"` Data json.RawMessage `json:"data,omitempty"` EncryptedData string `json:"encryptedData,omitempty"` }
Event holds a Serialized.io event.
type EventHandler ¶
type EventHandler struct { EventType string `json:"eventType,omitempty"` Functions []*Function `json:"functions,omitempty"` }
EventHandler contains the functions for modifying the current state of a projection.
type Function ¶
type Function struct { Function string `json:"function,omitempty"` TargetSelector string `json:"targetSelector,omitempty"` EventSelector string `json:"eventSelector,omitempty"` TargetFilter string `json:"targetFilter,omitempty"` EventFilter string `json:"eventFilter,omitempty"` RawData interface{} `json:"rawData,omitempty"` }
Function contains the templates for modifying projections.
type Projection ¶
type Projection struct { ID string `json:"projectionId,omitempty"` Data json.RawMessage `json:"data,omitempty"` }
Projection represents a model used to present your event data.
type ProjectionDefinition ¶
type ProjectionDefinition struct { Name string `json:"projectionName,omitempty"` Feed string `json:"feedName,omitempty"` Handlers []*EventHandler `json:"handlers,omitempty"` }
ProjectionDefinition contains the logic for how to build a projection.
type ReactionDefinition ¶
type ReactionDefinition struct { Name string `json:"reactionName,omitempty"` Feed string `json:"feedName,omitempty"` ReactOnEventType string `json:"reactOnEventType,omitempty"` CancelOnEventTypes []string `json:"cancelOnEventTypes,omitempty"` TriggerTimeField string `json:"triggerTimeField,omitempty"` Offset string `json:"offset,omitempty"` Action *Action `json:"action,omitempty"` }
ReactionDefinition holds a Serialized.io Reaction.