kv

package
v0.15.2-0...-1d34bd1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: AGPL-3.0-only Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV struct {
	sync.Mutex
	// contains filtered or unexported fields
}

KV implements a key value storage using a backend sql storage.

func New

func New(dbDriverName string, dbDataSourceName string, dbMigrationsBasePath string, logger logrus.FieldLogger) (*KV, error)

New creates a new KV using the provided options.

func (*KV) BatchCreateOrUpdate

func (kv *KV) BatchCreateOrUpdate(ctx context.Context, realm string, records []*Record) error

BatchCreateOrUpdate implements batch mode data storage.

func (*KV) Close

func (kv *KV) Close() error

Close closes the accociated KV including everything in it.

func (*KV) CreateOrUpdate

func (kv *KV) CreateOrUpdate(ctx context.Context, realm string, record *Record) error

CreateOrUpdate implements data storage.

func (*KV) Delete

func (kv *KV) Delete(ctx context.Context, realm string, record *Record) (bool, error)

Delete implements removal by key from data store.

func (*KV) Get

func (kv *KV) Get(ctx context.Context, realm string, record *Record) ([]*Record, error)

Get Implements data retrieval from the accociated store.

func (*KV) Initialize

func (kv *KV) Initialize(parentCtx context.Context) error

Initialize connects to the associated KV store and runs migrations as required.

func (*KV) Stmt

func (kv *KV) Stmt(ctx context.Context, id stmtID) (*sql.Stmt, error)

Stmt gets a statemen from the accociated kv with the provided ID.

type Record

type Record struct {
	Collection  *string
	Key         string
	Value       []byte
	ContentType string

	OwnerID  string
	ClientID string

	RequiredScopes string
}

A Record holds the data stored in a KV.

func (*Record) EncodeToJSON

func (r *Record) EncodeToJSON() (json.RawMessage, error)

EncodeToJSON encodes the accociated Record to JSON.

type RecordJSON

type RecordJSON struct {
	Key         *string         `json:"key"`
	Value       json.RawMessage `json:"value"`
	ContentType string          `json:"content_type,omitempty"`
}

A RecordJSON is the public JSON representation fo a Record.

Jump to

Keyboard shortcuts

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