store

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDriverNotExists = errors.New("store: driver does not exists")
)

errors

Functions

func Register

func Register(name string, driver Driver)

Register a new store driver for each configured database

Types

type Driver

type Driver interface {
	Open(ctx context.Context, connection string) (Store, error)
}

Driver initializes a Store interface and returns it

type Store

type Store interface {

	// Get retrieves a value from the storage and unmarshals it to the required type
	Get(ctx context.Context, collection, id string, value interface{}) (err error)

	// GetAll retrieves all the items for the required dataset
	GetAll(ctx context.Context, collection string) (values []map[string]interface{}, err error)

	// Set inserts/updates a item in the dataset
	Set(ctx context.Context, collection, id string, value interface{}) (err error)

	// Delete removes the required ID on the dataset
	Delete(ctx context.Context, collection, id string) (ok bool, err error)

	// Ping returns a non-nil error if the Store is not healthy or if the
	// connection to the persistence is compromised.
	Ping(ctx context.Context) error

	// Close releases the resources associated with the Store.
	Close() error
}

Store defines an interface that will be used to interact with the different data stores

func Open

func Open(ctx context.Context, driver, connection string) (Store, error)

Open the connection with the driver, using the connection string with the required data

Jump to

Keyboard shortcuts

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