badger

package
v0.0.0-...-9c41720 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(dbDir string) (eventhus.EventStore, error)

NewClient generates a new client for access to BadgerDB

Types

type AggregateDB

type AggregateDB struct {
	ID      string    `json:"_id"`
	Version int       `json:"version"`
	Events  []EventDB `json:"events"`
}

AggregateDB defines the collection to store the aggregate with their events

type Client

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

Client for access to boltdb

func (*Client) CloseClient

func (c *Client) CloseClient() error

CloseClient closes the db connection

func (*Client) Load

func (c *Client) Load(aggregateID string) ([]eventhus.Event, error)

Load the stored events for an AggregateID

func (*Client) SafeSave

func (c *Client) SafeSave(events []eventhus.Event, version int) error

SafeSave store the events without check the current version

func (*Client) Save

func (c *Client) Save(events []eventhus.Event, version int) error

Save the events ensuring the current version

type EventDB

type EventDB struct {
	Type        string `json:"event_type"`
	AggregateID string `json:"_id"`
	RawData     []byte `json:"data,omitempty"`

	Timestamp     time.Time `json:"timestamp"`
	AggregateType string    `json:"aggregate_type"`
	Version       int       `json:"version"`
	// contains filtered or unexported fields
}

EventDB defines the structure of the events to be stored

Jump to

Keyboard shortcuts

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