db

package
v0.0.0-...-fcfcbe3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 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

This section is empty.

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 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