db

package
v0.0.0-...-d850389 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("Request with given ID does not exist.")
)

Functions

func IsFailedDecode

func IsFailedDecode(err error) (string, bool)

IsFailedDecode determines whether the error is a failure to decode the config for a roller, and if so returns the ID of the roller and true.

Types

type DB

type DB interface {
	// Close cleans up resources associated with the DB.
	Close() error

	// Get returns the Config for the given roller.
	Get(ctx context.Context, rollerID string) (*config.Config, error)

	// GetAll returns Configs for all known rollers.
	GetAll(ctx context.Context) ([]*config.Config, error)

	// Put inserts the Config into the DB. Implementations MUST validate the
	// Config before inserting into the DB.
	Put(ctx context.Context, rollerID string, cfg *config.Config) error

	// Delete removes the Config for the given roller from the DB.
	Delete(ctx context.Context, rollerID string) error
}

DB provides methods for interacting with a database of Configs.

type FailedDecodeError

type FailedDecodeError struct {
	Err      error
	RollerID string
}

FailedDecodeError is an Error indicating that we failed to decode the config for a roller.

func (*FailedDecodeError) Error

func (e *FailedDecodeError) Error() string

Error implements error.

type FirestoreDB

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

firestoreB is a DB implementation backed by Firestore.

func NewDB

func NewDB(ctx context.Context, client *firestore.Client) (*FirestoreDB, error)

NewDB returns a DB instance backed by the given firestore.Client.

func NewDBWithParams

func NewDBWithParams(ctx context.Context, project, namespace, instance string, ts oauth2.TokenSource) (*FirestoreDB, error)

NewDBWithParams returns a DB instance backed by Firestore, using the given params.

func (*FirestoreDB) Close

func (d *FirestoreDB) Close() error

Close implements DB.

func (*FirestoreDB) Delete

func (d *FirestoreDB) Delete(ctx context.Context, rollerID string) error

Delete implements DB.

func (*FirestoreDB) Get

func (d *FirestoreDB) Get(ctx context.Context, rollerID string) (*config.Config, error)

Get implements DB.

func (*FirestoreDB) GetAll

func (d *FirestoreDB) GetAll(ctx context.Context) ([]*config.Config, error)

GetAll implements DB.

func (*FirestoreDB) Put

func (d *FirestoreDB) Put(ctx context.Context, rollerID string, cfg *config.Config) error

Put implements DB.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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