memory

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package memory provides an in-memory implementation of the lockbox.dev/accounts.Storer interface.

This implementation is useful for testing and demo setups in which data is not meant to be stored reliably or for a long time. All the data will be permanently lost when the service process exits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct{}

func (Factory) NewStorer

func (m Factory) NewStorer(ctx context.Context) (accounts.Storer, error)

func (Factory) TeardownStorers

func (m Factory) TeardownStorers() error

type Storer

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

Storer is an in-memory implementation of the Storer interface.

func NewStorer

func NewStorer() (*Storer, error)

NewStorer returns an in-memory Storer instance that is ready to be used as a Storer.

func (*Storer) Create

func (s *Storer) Create(ctx context.Context, account accounts.Account) error

Create inserts the passed Account into the Storer, returning an ErrAccountAlreadyExists error if an Account with the same ID already exists in the Storer.

func (*Storer) Delete

func (s *Storer) Delete(ctx context.Context, id string) error

Delete removes the Account that matches the specified ID from the Storer, if any Account matches the specified ID in the Storer.

func (*Storer) Get

func (s *Storer) Get(ctx context.Context, id string) (accounts.Account, error)

Get retrieves the Account specified by the passed ID from the Storer, returning an ErrAccountNotFound error if no Account matches the passed ID.

func (*Storer) ListByProfile

func (s *Storer) ListByProfile(ctx context.Context, profileID string) ([]accounts.Account, error)

ListByProfile returns all the Accounts associated with the passed profile ID, sorted with the most recently used Accounts coming first.

func (*Storer) Update

func (s *Storer) Update(ctx context.Context, id string, change accounts.Change) error

Update applies the passed Change to the Account that matches the specified ID in the Storer, if any Account matches the specified ID in the Storer.

Jump to

Keyboard shortcuts

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