Documentation

Index

Constants

View Source
const (
	SchemeDefaultPort       = 2113
	SchemaHostsSeparator    = ","
	SchemeName              = "esdb"
	SchemeNameWithDiscover  = "esdb+discover"
	SchemePathSeparator     = "/"
	SchemePortSeparator     = ":"
	SchemeQuerySeparator    = "?"
	SchemeSeparator         = "://"
	SchemeSettingSeparator  = "&"
	SchemeUserInfoSeparator = "@"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config     *Configuration
	Connection *grpc.ClientConn
	// contains filtered or unexported fields
}

    Client ...

    func NewClient

    func NewClient(configuration *Configuration) (*Client, error)

      NewClient ...

      func (*Client) AppendToStream

      func (client *Client) AppendToStream(context context.Context, streamID string, streamRevision stream_revision.StreamRevision, events []messages.ProposedEvent) (*WriteResult, error)

        AppendToStream ...

        func (*Client) Close

        func (client *Client) Close() error

          Close ...

          func (*Client) Connect

          func (client *Client) Connect() error

            Connect ...

            func (*Client) DeleteStream

            func (client *Client) DeleteStream(context context.Context, streamID string, streamRevision stream_revision.StreamRevision) (*DeleteResult, error)

              DeleteStream ...

              func (*Client) ReadAllEvents

              func (client *Client) ReadAllEvents(context context.Context, direction direction.Direction, from position.Position, count uint64, resolveLinks bool) ([]messages.RecordedEvent, error)

                ReadAllEvents ...

                func (*Client) ReadStreamEvents

                func (client *Client) ReadStreamEvents(context context.Context, direction direction.Direction, streamID string, from uint64, count uint64, resolveLinks bool) ([]messages.RecordedEvent, error)

                  ReadStreamEvents ...

                  func (*Client) SubscribeToAll

                  func (client *Client) SubscribeToAll(context context.Context, from position.Position, resolveLinks bool, eventAppeared func(messages.RecordedEvent), checkpointReached func(position.Position), subscriptionDropped func(reason string)) (*subscription.Subscription, error)

                    SubscribeToAll ...

                    func (*Client) SubscribeToAllFiltered

                    func (client *Client) SubscribeToAllFiltered(context context.Context, from position.Position, resolveLinks bool, filterOptions filtering.SubscriptionFilterOptions, eventAppeared func(messages.RecordedEvent), checkpointReached func(position.Position), subscriptionDropped func(reason string)) (*subscription.Subscription, error)

                      SubscribeToAllFiltered ...

                      func (*Client) SubscribeToStream

                      func (client *Client) SubscribeToStream(context context.Context, streamID string, from uint64, resolveLinks bool, eventAppeared func(messages.RecordedEvent), checkpointReached func(position.Position), subscriptionDropped func(reason string)) (*subscription.Subscription, error)

                        SubscribeToStream ...

                        func (*Client) TombstoneStream

                        func (client *Client) TombstoneStream(context context.Context, streamID string, streamRevision stream_revision.StreamRevision) (*DeleteResult, error)

                          Tombstone ...

                          type Configuration

                          type Configuration struct {
                          	// The URI of the EventStoreDB. Use this when connecting to a single node.
                          	// Example: localhost:2113
                          	Address string
                          
                          	// An array of end points used to seed gossip.
                          	GossipSeeds []string
                          
                          	// Disable communicating over a secure channel.
                          	DisableTLS bool // Defaults to false.
                          
                          	// The NodePreference to use when connecting.
                          	NodePreference NodePreference
                          
                          	// The username to use for authenticating against the EventStoreDB instance.
                          	Username string
                          
                          	// The password to use for authenticating against the EventStoreDB instance.
                          	Password string
                          
                          	// RootCAs defines the set of root certificate authorities
                          	// that clients use when verifying server certificates.
                          	// If RootCAs is nil, TLS uses the host's root CA set.
                          	RootCAs *x509.CertPool // Defaults to nil.
                          
                          	// Allows to skip certificate validation.
                          	SkipCertificateVerification bool // Defaults to false.
                          
                          	// The maximum number of times to attempt end point discovery.
                          	MaxDiscoverAttempts int // Defaults to 10.
                          
                          	// The polling interval (in milliseconds) used to discover the end point.
                          	DiscoveryInterval int // Defaults to 100 milliseconds.
                          
                          	// The amount of time (in seconds) after which an attempt to discover gossip will fail.
                          	GossipTimeout int // Defaults to 5 seconds.
                          
                          	// Specifies if DNS discovery should be used.
                          	DnsDiscover bool // Defaults to false.
                          
                          	// The amount of time (in milliseconds) to wait after which a keepalive ping is sent on the transport.
                          	// If set below 10s, a minimum value of 10s will be used instead. Use -1 to disable. Use -1 to disable.
                          	KeepAliveInterval time.Duration // Defaults to 10 seconds.
                          
                          	// The amount of time (in milliseconds) the sender of the keep alive ping waits for an acknowledgement.
                          	KeepAliveTimeout time.Duration // Defaults to 10 seconds.
                          }

                            Configuration describes how to connect to an instance of EventStoreDB.

                            func ParseConnectionString

                            func ParseConnectionString(connectionString string) (*Configuration, error)

                              ParseConnectionString creates a Configuration based on an EventStoreDb connection string.

                              type DeleteResult

                              type DeleteResult struct {
                              	Position position.Position
                              }

                                DeleteResult ...

                                type EndpointDiscoverer

                                type EndpointDiscoverer interface {
                                	Discover() (*MemberInfo, error)
                                }

                                  EndpointDiscoverer func that is used to discover an endpoint given the gossip seeds

                                  type GossipEndpointDiscoverer

                                  type GossipEndpointDiscoverer struct {
                                  	MaxDiscoverAttempts       int
                                  	GossipSeeds               []*url.URL
                                  	NodePreference            NodePreference
                                  	SkipCertificateValidation bool
                                  	// contains filtered or unexported fields
                                  }

                                    GossipEndpointDiscoverer used for discovering and picking the most appropriate node in a cluster

                                    func NewGossipEndpointDiscoverer

                                    func NewGossipEndpointDiscoverer() *GossipEndpointDiscoverer

                                    func (*GossipEndpointDiscoverer) Discover

                                    func (discoverer *GossipEndpointDiscoverer) Discover() (*MemberInfo, error)

                                      Discover will discover nodes via performing a gossip over HTTP and then picking the best candidate to connect to

                                      type GossipResponse

                                      type GossipResponse struct {
                                      	Members []MemberInfo `json:"members"`
                                      }

                                        GossipResponse represents the response from a gossip request

                                        type GossipSeed

                                        type GossipSeed struct {
                                        	ExternalTCPIP    string
                                        	ExternalHTTPPort int
                                        }

                                          GossipSeed represents and endpoint where a gossip can be issued and nodes in a cluster discovered

                                          type MemberInfo

                                          type MemberInfo struct {
                                          	State            NodeState `json:"state"`
                                          	IsAlive          bool      `json:"isAlive"`
                                          	ExternalTCPIP    string    `json:"externalTcpIp"`
                                          	ExternalTCPPort  int       `json:"externalTcpPort"`
                                          	HttpEndPointIP   string    `json:"HttpEndPointIp"`
                                          	HttpEndPointPort int       `json:"HttpEndPointPort"`
                                          }

                                            MemberInfo represents the members in a cluster which is retrieved as part of the gossip request and lives inside of the members in the response

                                            type NodePreference

                                            type NodePreference string
                                            const (
                                            	NodePreference_Leader          NodePreference = "Leader"
                                            	NodePreference_Follower        NodePreference = "Follower"
                                            	NodePreference_ReadOnlyReplica NodePreference = "ReadOnlyReplica"
                                            	NodePreference_Random          NodePreference = "Random"
                                            )

                                            func (NodePreference) String

                                            func (nodePreference NodePreference) String() string

                                            type NodeState

                                            type NodeState string
                                            const (
                                            	Leader             NodeState = "Leader"
                                            	Follower           NodeState = "Follower"
                                            	Manager            NodeState = "Manager"
                                            	Shutdown           NodeState = "Shutdown"
                                            	Unknown            NodeState = "Unknown"
                                            	Initializing       NodeState = "Initializing"
                                            	CatchingUp         NodeState = "CatchingUp"
                                            	ResigningLeader    NodeState = "ResigningLeader"
                                            	ShuttingDown       NodeState = "ShuttingDown"
                                            	PreLeader          NodeState = "PreLeader"
                                            	PreReplica         NodeState = "PreReplica"
                                            	PreReadOnlyReplica NodeState = "PreReadOnlyReplica"
                                            	Clone              NodeState = "Clone"
                                            	DiscoverLeader     NodeState = "DiscoverLeader"
                                            	ReadOnlyLeaderless NodeState = "ReadOnlyLeaderless"
                                            	ReadOnlyReplica    NodeState = "ReadOnlyReplica"
                                            )

                                            func (NodeState) String

                                            func (nodeState NodeState) String() string

                                            type WriteResult

                                            type WriteResult struct {
                                            	CommitPosition      uint64
                                            	PreparePosition     uint64
                                            	NextExpectedVersion uint64
                                            }

                                              WriteResult ...

                                              Directories

                                              Path Synopsis