repository

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventsCollectionName = "events"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryRepository

type InMemoryRepository struct {
	// contains filtered or unexported fields
}

An in-memory repository for test purposes only.

func NewInMemoryRepository

func NewInMemoryRepository() *InMemoryRepository

func (*InMemoryRepository) AppendEvent

func (*InMemoryRepository) GetStreamEvents

FIXME events are not immutable as they would be from a database. I do not think it is necessary to fix for now.

func (*InMemoryRepository) GetStreamInfo

type MongoRepository

type MongoRepository struct {
	// contains filtered or unexported fields
}

func NewMongoRepository

func NewMongoRepository(ctx context.Context, client *mongo.Client, dbName string) (*MongoRepository, error)

func (*MongoRepository) AppendEvent

AppendEventImpl appends a new event to the specified stream in MongoDB Assumes that all the optimistic locking has been performed by AbstractCachingJournal

func (*MongoRepository) GetStreamEvents

func (*MongoRepository) GetStreamInfo

type PostgresRepository

type PostgresRepository struct {
	annales.UnimplementedJournalServer
	// contains filtered or unexported fields
}

func NewPostgresRepository

func NewPostgresRepository(db *sql.DB) (*PostgresRepository, error)

func (*PostgresRepository) AppendEvent

func (*PostgresRepository) GetStreamEvents

GetEventsByStream retrieves all events belonging to a specific stream_id

func (*PostgresRepository) GetStreamInfo

type Repository

type Repository interface {
	AppendEvent(ctx context.Context, in *annales.AppendEventRequest) (*annales.AppendEventResponse, error)
	GetStreamInfo(ctx context.Context, in *annales.GetStreamInfoRequest) (*annales.GetStreamInfoResponse, error)
}

A Repository is a database-specific implementation of the appender and the peeker. It is not require to think about optimistic locking or caching, that is a responsibility of the journal. Yes, the interface definition is a bit opaque but the objective is to avoid unnecessary allocations and data mappings.

Jump to

Keyboard shortcuts

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