{"modulePath":"github.com/get-eventually/go-eventually/eventstore/postgres","version":"v0.1.0-alpha.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package postgres\n\nPackage postgres contains an Event Store implementation using PostgreSQL as backend data store.\n\n## Functions\n\n```go\nfunc RunMigrations(dsn string) error\n```\nRunMigrations performs the migrations for the Postgres database.\n\n## Types\n\n```go\ntype AppendToStoreFunc func(\n\tctx context.Context,\n\ttx *sql.Tx,\n\tid stream.ID,\n\texpected eventstore.VersionCheck,\n\teventName string,\n\tpayload []byte,\n\tmetadata []byte,\n) (int64, error)\n```\nAppendToStoreFunc is the function type used by the postgres.EventStore to delegate the append call to the database instace.\n\n```go\ntype Checkpointer struct {\n\tDB     *sql.DB\n\tLogger logger.Logger\n}\n```\nCheckpointer is a checkpoint.Checkpointer implementation using Postgres as a storage backend.\n\n```go\nfunc (c Checkpointer) Read(ctx context.Context, subscriptionName string) (int64, error)\n```\nRead reads the latest checkpointed sequence number of the subscription specified.\n\n```go\nfunc (c Checkpointer) Write(ctx context.Context, subscriptionName string, sequenceNumber int64) error\n```\nWrite checkpoints the sequence number value provided for the specified subscription.\n\n```go\ntype Deserializer interface {\n\tDeserialize(eventType string, eventStreamID stream.ID, data []byte) (eventually.Payload, error)\n}\n```\nDeserializer can be used by the EventStore to delegate deserialization of a Domain Event from binary format to its corresponding Domain Object.\n\n```go\ntype DeserializerFunc func(eventType string, eventStreamID stream.ID, data []byte) (eventually.Payload, error)\n```\nDeserializerFunc is a functional type that implements the Deserializer interface.\n\n```go\nfunc (fn DeserializerFunc) Deserialize(eventType string, eventStreamID stream.ID, data []byte) (eventually.Payload, error)\n```\nDeserialize delegates the function call to the inner function value.\n\n```go\ntype EventStore struct {\n\t// contains filtered or unexported fields\n}\n```\nEventStore is an eventstore.Store implementation which uses PostgreSQL as backend datastore.\n\n```go\nfunc NewEventStore(db *sql.DB, serde Serde, options ...Option) EventStore\n```\nNewEventStore creates a new EventStore using the database connection pool provided.\n\n```go\nfunc (st EventStore) Append(\n\tctx context.Context,\n\tid stream.ID,\n\texpected eventstore.VersionCheck,\n\tevents ...eventually.Event,\n) (v int64, err error)\n```\nAppend inserts the specified Domain Events into the Event Stream specified by the current instance, returning the new version of the Event Stream.\n\nA version can be specified to enable an Optimistic Concurrency check on append, by using the expected version of the Event Stream prior to appending the new Events.\n\nAlternatively, VersionCheckAny can be used if no Optimistic Concurrency check should be carried out.\n\n```go\nfunc (st EventStore) LatestSequenceNumber(ctx context.Context) (int64, error)\n```\nLatestSequenceNumber returns the latest Sequence Number used by a Domain Event committed to the Event Store.\n\n```go\nfunc (st EventStore) Stream(\n\tctx context.Context,\n\tes eventstore.EventStream,\n\ttarget stream.Target,\n\tselectt eventstore.Select,\n) error\n```\nStream opens one or more Event Streams depending on the provided target.\n\nIn case of multi-Event Streams targets, the Select value specified will be applied over the value of the Global Sequence Number of the events. In case of a single Event Stream, this is applied over the Version value.\n\n```go\ntype FusedSerde struct {\n\tSerializer\n\tDeserializer\n}\n```\nFusedSerde is a convenience type to fuse a Serializer and Deserializer in a Serde instance.\n\n```go\ntype JSONRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nJSONRegistry is a Serde type that serializes and deserializes into and from the JSON representation of eventually.Payload types registered.\n\nGiven the current limitation of Go with generics, the only way to provide type information for deserialization is to use interfaces and reflection.\n\n```go\nfunc NewJSONRegistry() JSONRegistry\n```\nNewJSONRegistry creates a new registry for deserializing event types, using the provided deserializer.\n\n```go\nfunc (r JSONRegistry) Deserialize(eventType string, eventStreamID stream.ID, data []byte) (eventually.Payload, error)\n```\nDeserialize attempts to deserialize a raw message with the type referenced by the supplied event type identifier.\n\n```go\nfunc (r JSONRegistry) Register(events ...eventually.Payload) error\n```\nRegister adds the type information to this registry for all the provided Payload types.\n\nAn error is returned if any of the provided events is nil, or if two different event types with the same type identifier (from the Payload.Name() method) have been provided.\n\n```go\nfunc (r JSONRegistry) Serialize(eventType string, eventStreamID stream.ID, event eventually.Payload) ([]byte, error)\n```\nSerialize serializes a Domain Event using its JSON representation.\n\n```go\ntype Option func(EventStore) EventStore\n```\nOption defines a type for providing additional constructor adjustments for postgres.EventStore.\n\n```go\nfunc WithAppendMiddleware(wrap func(AppendToStoreFunc) AppendToStoreFunc) Option\n```\nWithAppendMiddleware allows overriding the internal logic for appending events within a transaction.\n\n```go\ntype Serde interface {\n\tSerializer\n\tDeserializer\n}\n```\nSerde is a serializer/deserializer type that can be used by the EventStore to serialize Domain Events to and deserialize Domain Events from the store.\n\n```go\ntype Serializer interface {\n\tSerialize(eventType string, eventStreamID stream.ID, event eventually.Payload) ([]byte, error)\n}\n```\nSerializer can be used by the EventStore to delegate serialization of a Domain Event from the eventually.Payload format (domain object) to binary format.\n\n```go\ntype SerializerFunc func(eventType string, eventStreamID stream.ID, event eventually.Payload) ([]byte, error)\n```\nSerializerFunc is a functional type that implements the Serializer interface.\n\n```go\nfunc (fn SerializerFunc) Serialize(eventType string, eventStreamID stream.ID, event eventually.Payload) ([]byte, error)\n```\nSerialize delegates the function call to the inner function value.\n\n","path":"github.com/get-eventually/go-eventually/eventstore/postgres","name":"postgres","synopsis":"Package postgres contains an Event Store implementation using PostgreSQL as backend data store.","isRedistributable":true}
