memory

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package memory implements storage interfaces for bolt key-value store database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DevicesStorage

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

DevicesStorage implements storage.Devices interface for bolt database.

func (*DevicesStorage) All

func (s *DevicesStorage) All(ctx context.Context) ([]models.Device, error)

All returns slice with all devices from storage.

func (*DevicesStorage) New

func (d *DevicesStorage) New(ctx context.Context, userID string, newDevice models.Device) (string, error)

New stores given devices data in database and returns new device (given in new model) id.

func (*DevicesStorage) NewByOwner added in v0.3.1

func (d *DevicesStorage) NewByOwner(ctx context.Context, deviceOwner string, newDevice models.Device) (string, error)

NewByOwner stores given devices (owned by user with given nickname) data in database and returns its id.

func (*DevicesStorage) OfUser

func (d *DevicesStorage) OfUser(ctx context.Context, userID string) ([]models.Device, error)

OfUser returns list of models owned by user with given id.

func (*DevicesStorage) Read

func (s *DevicesStorage) Read(ctx context.Context, id string) (*models.Device, error)

Read returns single device data with given ID.

func (*DevicesStorage) Remove

func (s *DevicesStorage) Remove(ctx context.Context, id string) error

Remove deletes device with given id from storage.

func (*DevicesStorage) Update

func (s *DevicesStorage) Update(ctx context.Context, d models.Device) error

Update overwrites existing device data.

type Factory

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

Factory implements storage.Factory interface for bolt database.

func New

func New(db *bolt.DB) (*Factory, error)

New returns pointer to new memory storage Factory.

func (Factory) Devices

func (f Factory) Devices() storage.Devices

func (Factory) StatusTx added in v0.3.2

func (f Factory) StatusTx() *StatusStorageTx

StatusTx returns storage interface for reading and writing information about numbers of online users and unkown devices.

func (Factory) TwoFactor added in v0.4.0

func (f Factory) TwoFactor() storage.TwoFactor

func (Factory) Users

func (f Factory) Users() storage.Users

Users returns storage interface for manipulating users data.

type StatusStorageTx added in v0.3.2

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

StatusStorageTx implements storage.StatusTx interface.

func (*StatusStorageTx) DevicesStatus added in v0.3.2

func (s *StatusStorageTx) DevicesStatus(
	ctx context.Context,
	f func(context.Context, storage.Status) error,
) error

DevicesStatus accepts function that manipulates number of unknown devices and online users in single safe transaction.

type TwoFactorStorage added in v0.4.0

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

TwoFactorStorage implements TwoFactor storage interface for bolt database.

func (*TwoFactorStorage) Get added in v0.4.0

func (t *TwoFactorStorage) Get(ctx context.Context, userID string) (*models.TwoFactor, error)

Get returns two factor methods for user with given user ID.

func (*TwoFactorStorage) Remove added in v0.4.0

func (t *TwoFactorStorage) Remove(ctx context.Context, userID string) error

Remove deletes all two factor methods of user with given user ID. You can still use Update method after all to start adding more methods.

func (*TwoFactorStorage) Update added in v0.4.0

func (t *TwoFactorStorage) Update(ctx context.Context, userID string, f func(*models.TwoFactor) error) error

Updates apply given function to two factor methods of user with given user ID.

type UsersStorage

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

UsersStorage implements storage.Users interface for bolt database.

func (*UsersStorage) All

All returns slice with all users from storage.

func (*UsersStorage) New

func (s *UsersStorage) New(ctx context.Context, newUser storage.UserEntry) (string, error)

New stores given user data in database and returns assigned (given) id.

func (*UsersStorage) Read

func (s *UsersStorage) Read(ctx context.Context, id string) (*storage.UserEntry, error)

Read returns single user data with given ID.

func (*UsersStorage) Remove

func (s *UsersStorage) Remove(ctx context.Context, id string) error

Remove deletes user with given id from storage.

func (*UsersStorage) Update

func (s *UsersStorage) Update(ctx context.Context, id string, f func(*storage.UserEntry) error) error

Update overwrites existing user data.

Jump to

Keyboard shortcuts

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