Documentation ¶
Overview ¶
Package goro is pure Go client library for dealing with Event Store (versions 3.2.0 and later). It includes a high-level API for reading and writing events. Usage examples for the high-level APIs are provided inline with their full documentation.
Index ¶
- Constants
- Variables
- type Acknowledger
- type Action
- type Author
- type Client
- func (c Client) BackwardsReader(stream string) Reader
- func (c Client) CatchupSubscription(stream string, start int64) Subscriber
- func (c Client) FowardsReader(stream string) Reader
- func (c Client) PersistentSubscription(stream, subscriptionName string, settings PersistentSubscriptionSettings) (Subscriber, error)
- func (c Client) Sling() *sling.Sling
- func (c Client) Writer(stream string) Writer
- type ClientOption
- type Event
- type Events
- type PersistentSubscriptionSettings
- type Reader
- type Slinger
- type SlingerFunc
- type StreamMessage
- type Subscriber
- func NewCatchupSubscription(slinger Slinger, stream string, startFrom int64) Subscriber
- func NewPersistentSubscription(slinger Slinger, stream, subscriptionName string, ...) (Subscriber, error)
- func UpdatePersistentSubscription(subscription Subscriber, newSettings PersistentSubscriptionSettings) (Subscriber, error)
- type Writer
Constants ¶
const ( ActionPark Action = "park" ActionRetry = "retry" ActionSkip = "skip" ActionStop = "stop" )
Action enum
const ( ExpectedVersionAny int64 = -2 ExpectedVersionNone int64 = -1 ExpectedVersionEmpty int64 = 0 )
ExpectedVersions
Variables ¶
var ( ErrStreamNeverCreated = errors.New("stream never created") ErrInvalidContentType = errors.New("invalid content type") ErrStreamNotFound = errors.New("the stream was not found") ErrInternalError = errors.New("internall error has occurred") )
errors
Functions ¶
This section is empty.
Types ¶
type Acknowledger ¶
Acknowledger can acknowledge or Not-Acknowledge an Event in a Persistent Subscription
type Author ¶
type Author struct {
Name string `json:"name"`
}
Author represents the Author of an Event
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a connection to an event store
func Connect ¶
func Connect(host string, options ...ClientOption) *Client
Connect creates a new client
func (Client) BackwardsReader ¶
BackwardsReader creates a new Reader that reads backwards on a stream
func (Client) CatchupSubscription ¶
func (c Client) CatchupSubscription(stream string, start int64) Subscriber
CatchupSubscription creates a new catchup style subscription that starts reading at an event number and continues forwards
func (Client) FowardsReader ¶
FowardsReader creates a new Reader that reads forwards on a stream
func (Client) PersistentSubscription ¶
func (c Client) PersistentSubscription(stream, subscriptionName string, settings PersistentSubscriptionSettings) (Subscriber, error)
PersistentSubscription creates a new competing consumer style subscription with the given settings
type ClientOption ¶
type ClientOption func(*Client)
ClientOption applies options to a client
func WithBasicAuth ¶
func WithBasicAuth(username, password string) ClientOption
WithBasicAuth adds basic authentication to the Event Store
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets the http.Client for the Client
type Event ¶
type Event struct { At time.Time `json:"updated,omitempty"` Author Author `json:"author,omitempty"` Stream string `json:"streamId,omitempty"` Type string `json:"eventType"` PositionStream string `json:"positionStreamId,omitempty"` Data json.RawMessage `json:"data,omitempty"` Metadata json.RawMessage `json:"metadata,omitempty"` ID uuid.UUID `json:"eventID"` Version int64 `json:"eventNumber"` Position int64 `json:"positionEventNumber,omitempty"` }
Event represents an Event in Event Store the data and Metadata must be json encoded
func CreateEvent ¶
func CreateEvent(eventType string, data, metadata json.RawMessage, version int64) Event
CreateEvent initializes a new Event with an event type, some data, metadata, and a version you specify. It then creates a random uuid and sets the time it was created at.
type Events ¶
type Events []Event
Events is an array of events that implements the sort.Interface interface.
type PersistentSubscriptionSettings ¶
type PersistentSubscriptionSettings struct { ResolveLinkTos bool `json:"resolveLinktos,omitempty"` StartFrom int64 `json:"startFrom,omitempty"` ExtraStatistics bool `json:"extraStatistics,omitempty"` CheckPointAfterMilliseconds int64 `json:"checkPointAfterMilliseconds,omitempty"` LiveBufferSize int `json:"liveBufferSize,omitempty"` ReadBatchSize int `json:"readBatchSize,omitempty"` BufferSize int `json:"bufferSize,omitempty"` MaxCheckPointCount int `json:"maxCheckPointCount,omitempty"` MaxRetryCount int `json:"maxRetryCount,omitempty"` MaxSubscriberCount int `json:"maxSubscriberCount,omitempty"` MessageTimeoutMilliseconds int64 `json:"messageTimeoutMilliseconds,omitempty"` MinCheckPointCount int `json:"minCheckPointCount,omitempty"` NamedConsumerStrategy string `json:"namedConsumerStrategy,omitempty"` }
PersistentSubscriptionSettings represents the settings for creating and updating a Persistent subscription. You can read more about those settings in the Event Store documentation [here](https://eventstore.org/docs/http-api/4.0.2/competing-consumers/#creating-a-persistent-subscription).
type Reader ¶
Reader reads a couple of Events from a stream
func NewBackwardsReader ¶
NewBackwardsReader creates a Reader that reads events backwards
func NewForwardsReader ¶
NewForwardsReader creates a Reader that reads events forwards
type SlingerFunc ¶
SlingerFunc is something that can return a sling object
func (SlingerFunc) Sling ¶
func (f SlingerFunc) Sling() *sling.Sling
Sling implements the Slinger interface
type StreamMessage ¶
type StreamMessage struct { Event Event Acknowledger Acknowledger Error error }
StreamMessage contains an Event or an error
func (StreamMessage) Nack ¶
func (m StreamMessage) Nack(action Action) error
Nack rejects“ an Event or fails
type Subscriber ¶
type Subscriber interface {
Subscribe(ctx context.Context) <-chan StreamMessage
}
Subscriber streams events
func NewCatchupSubscription ¶
func NewCatchupSubscription(slinger Slinger, stream string, startFrom int64) Subscriber
NewCatchupSubscription creates a Subscriber that starts reading a stream from a specific event and then catches up to the head of the stream.
func NewPersistentSubscription ¶
func NewPersistentSubscription(slinger Slinger, stream, subscriptionName string, settings PersistentSubscriptionSettings) (Subscriber, error)
NewPersistentSubscription creates a new subscription that implements the competing consumers pattern
func UpdatePersistentSubscription ¶
func UpdatePersistentSubscription(subscription Subscriber, newSettings PersistentSubscriptionSettings) (Subscriber, error)
UpdatePersistentSubscription updates an existing subscription if it's Persistent