data

package
v0.0.0-...-44efded Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoffeeCollection = "coffees"
View Source
var NotFound = errors.New("not found")

Functions

func InitTestData

func InitTestData(db *mongo.Database) error

func NewDbConnection

func NewDbConnection() (*mongo.Database, error)

Types

type CoffeeRepository

type CoffeeRepository interface {
	Get(id string) (entities.Coffee, error)
	GetAll() entities.Coffees
	Add(ctx context.Context, name string) entities.Coffee
	WithTransaction(f func(ctx context.Context) error) error
}

CoffeeRepository is the command/query interface this repository supports.

func NewInMemoryCoffeeRepository

func NewInMemoryCoffeeRepository() (CoffeeRepository, error)

func NewMongoCoffeeRepository

func NewMongoCoffeeRepository(db *mongo.Database) (CoffeeRepository, error)

type InMemoryCoffeeRepository

type InMemoryCoffeeRepository struct {
}

InMemoryCoffeeRepository is a placeholder in memory db

func (*InMemoryCoffeeRepository) Add

Add adds a coffee

func (*InMemoryCoffeeRepository) Get

Get retrieves a coffee by id

func (*InMemoryCoffeeRepository) GetAll

GetAll gets a list of all coffees

func (*InMemoryCoffeeRepository) WithTransaction

func (r *InMemoryCoffeeRepository) WithTransaction(handler func(ctx context.Context) error) error

type InMemoryOutboxRepository

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

func (*InMemoryOutboxRepository) GetUnsent

func (db *InMemoryOutboxRepository) GetUnsent() []entities.OutboxEntry

func (*InMemoryOutboxRepository) MarkSent

func (db *InMemoryOutboxRepository) MarkSent(id string) error

func (*InMemoryOutboxRepository) SendMessage

func (db *InMemoryOutboxRepository) SendMessage(ctx context.Context, topic string, message []byte) (string, error)

type MongoCoffeeRepository

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

func (MongoCoffeeRepository) Add

func (MongoCoffeeRepository) Get

func (MongoCoffeeRepository) GetAll

func (MongoCoffeeRepository) WithTransaction

func (m MongoCoffeeRepository) WithTransaction(handler func(ctx context.Context) error) error

type MongoOutboxRepository

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

func (MongoOutboxRepository) GetUnsent

func (m MongoOutboxRepository) GetUnsent() []entities.OutboxEntry

func (MongoOutboxRepository) MarkSent

func (m MongoOutboxRepository) MarkSent(id string) error

func (MongoOutboxRepository) SendMessage

func (m MongoOutboxRepository) SendMessage(ctx context.Context, topic string, message []byte) (string, error)

type OutboxRepository

type OutboxRepository interface {
	SendMessage(ctx context.Context, topic string, message []byte) (string, error)
	GetUnsent() []entities.OutboxEntry
	MarkSent(id string) error
}

func NewInMemoryOutboxRepository

func NewInMemoryOutboxRepository() OutboxRepository

func NewMongoOutboxRepository

func NewMongoOutboxRepository(db *mongo.Database) (OutboxRepository, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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