Version: v0.19.0 Latest Latest

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 4 Imported by: 0



Package kv contains wrapper implementations over generic KV storage.



This section is empty.


View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is a special error to return when given key not found.


This section is empty.


type Credentials

type Credentials struct {
	// contains filtered or unexported fields

Credentials is a generic implementation of credential storage over key-value Storage.

func NewCredentials

func NewCredentials(storage Storage) Credentials

NewCredentials creates new Credentials.

func (Credentials) Password

func (c Credentials) Password(ctx context.Context) (string, error)

Password implements Credentials and returns password.

func (Credentials) Phone

func (c Credentials) Phone(ctx context.Context) (string, error)

Phone implements Credentials and returns phone.

func (Credentials) SavePassword

func (c Credentials) SavePassword(ctx context.Context, password string) error

SavePassword stores given password to storage.

func (Credentials) SavePhone

func (c Credentials) SavePhone(ctx context.Context, phone string) error

SavePhone stores given phone to storage.

func (Credentials) WithPasswordKey

func (c Credentials) WithPasswordKey(passwordKey string) Credentials

WithPasswordKey sets password key to use.

func (Credentials) WithPhoneKey

func (c Credentials) WithPhoneKey(phoneKey string) Credentials

WithPhoneKey sets phone key to use.

type Session

type Session struct {
	// contains filtered or unexported fields

Session is a generic implementation of session storage over key-value Storage.

func NewSession

func NewSession(storage Storage, key string) Session

NewSession creates new Session.

func (Session) LoadSession

func (s Session) LoadSession(ctx context.Context) ([]byte, error)

LoadSession loads session using given key from storage.

func (Session) StoreSession

func (s Session) StoreSession(ctx context.Context, data []byte) error

StoreSession saves session using given key to storage.

type Storage

type Storage interface {
	Set(ctx context.Context, k, v string) error
	Get(ctx context.Context, k string) (string, error)

Storage represents generic KV storage.

Jump to

Keyboard shortcuts

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