model

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 2 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Action is the action being performed by event.
	// Examples: register_user, new_item_inventory etc.
	Action string `json:"action"`

	// AggregateID is the ID of aggregate responsible for consuming event.
	AggregateID int8 `json:"aggregate_id"`

	// Data is the data contained by event,
	Data string `json:"data"`

	// Timestamp is the time when the event was generated.
	Timestamp time.Time `json:"timestamp"`

	// UserID is the associated user's id who generated the event.
	UserID int `json:"user_id"`

	// UUID is the unique-indentifier for event.
	UUID gocql.UUID `json:"uuid"`

	// Version is the version for events as processed for aggregate-projection.
	// This is incremented by the aggregate itself each time an aggregate
	// projection is updated.
	Version int64 `json:"version"`

	// Year bucket is the year in which the event was generated.
	// This is used as the partitioning key.
	YearBucket int16 `json:"year_bucket"`
}

Event is an event to be stored in event-store.

type EventMeta

type EventMeta struct {
	// AggregateVersion tracks the version to be used
	// by new events for that aggregate.
	AggregateVersion int64 `json:"aggregate_version"`
	// AggregateID corresponds to AggregateID in
	// event-store and ID in aggregate-projection.
	AggregateID int8 `json:"aggregate_id"`
	// Year bucket is the year in which the event was generated.
	// This is used as the partitioning key.
	YearBucket int16 `json:"year_bucket"`
}

EventMeta contains the information about hydrating Aggregate-Projections. The AggregateVersion tracks the version to be used by new events for that aggregate. This difference between the aggregate-projection version and AggregateVersion gives us the versions of the events yet to be applied to the aggregate projection.

type EventStoreQuery added in v1.2.1

type EventStoreQuery struct {
	// AggregateID is the id for aggregate whose events are to be fetched
	AggregateID int8 `json:"aggregate_id"`
	// AggregateVersion is the highest version of events that have been
	// already fetched by the aggregate. The event-store will be queried
	// for events greater than this version.
	AggregateVersion int64 `json:"aggregate_version"`
	// YearBucket is the partitioning-key for the Cassandra table.
	// Specify this to let the query-handler know which partition to
	// user for query operations.
	YearBucket int16 `json:"year_bucket"`
}

EventStoreQuery can be used to fetch later events than the specified version.

type KafkaResponse

type KafkaResponse struct {
	// AggregateID is the ID of aggregate the response is for.
	AggregateID int8 `json:"aggregate_id,omitempty"`
	// CorrelationID can be used to "identify" responses, such as checking
	// if the response if for some particular request.
	CorrelationID string `json:"correlation_id,omitempty"`
	// Input is the message-input received by Consumer.
	// Use this to provide context of whatever data was attempted to be processed.
	Input string `json:"input"`
	// Error is the error occurred while processing the Input.
	// Convert errors to strings, this is just an indication that
	// something went wrong, so we can signal/display-error to end-
	// user. Blank Error-string means everything was fine.
	Error string `json:"error"`
	// Result is the result after an input was processed.
	// This is some data returned by processing (such as database results) etc.
	Result string `json:"result,omitempty"`
}

KafkaResponse is the response from consuming a Kafka message and operating on it. This can be used to as a "response-back" to indicate if the operation was successful or not.

Jump to

Keyboard shortcuts

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