storage

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package storage provides a store wrapper over go-micro's store.Store and several implementations.

The store package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.

Package storage provides a store wrapper over go-micro's store.Store and several implementations.

The store package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.

Package storage provides a store wrapper over go-micro's store.Store and several implementations.

The store package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.

Package storage provides a store wrapper over go-micro's store.Store and several implementations.

The store package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.

Package storage provides a store wrapper over go-micro's store.Store and several implementations.

The store package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration. TODO: Refactor the interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteOption

type DeleteOption func(d *DeleteOptions)

DeleteOption sets values in DeleteOptions.

func DeleteFrom

func DeleteFrom(database, table string) DeleteOption

Sets database and database table.

func DeleteKey

func DeleteKey(val string) DeleteOption

Sets filter's field name.

func DeleteValue

func DeleteValue(val string) DeleteOption

Sets filter's field value.

type DeleteOptions

type DeleteOptions struct {
	Database, Table string
	Key             string
	Value           string
}

DeleteOptions configures an individual Delete operation.

type ReadOption

type ReadOption func(l *ReadOptions)

func ReadFrom

func ReadFrom(database, table string) ReadOption

Sets database and database table read options.

func ReadKey

func ReadKey(val string) ReadOption

Sets a filter field name.

func ReadLimit

func ReadLimit(val uint) ReadOption

Sets select limit value.

func ReadOffset

func ReadOffset(val uint) ReadOption

Sets select skip value.

func ReadPrefix

func ReadPrefix(val string) ReadOption

Sets a filter prefix value.

func ReadResult

func ReadResult(val any) ReadOption

Sets a pointer to populate it with the result.

func ReadSuffix

func ReadSuffix(val string) ReadOption

Sets a filter suffix value.

func ReadValue

func ReadValue(val string) ReadOption

Sets a filter field's name's value.

type ReadOptions

type ReadOptions struct {
	// List from the following.
	Database, Table string
	// Key to read.
	Key string
	// Value to read (optional).
	Value string
	// Prefix returns all keys that are prefixed with key.
	Prefix string
	// Suffix returns all keys that end with key.
	Suffix string
	// Limit limits the number of returned keys.
	Limit uint
	// Offset when combined with Limit supports pagination.
	Offset uint
	// Result from the executed query.
	Result any
}

type RefinedStore

type RefinedStore interface {
	Init(opts ...store.Option) error
	List(ctx context.Context, opts ...ReadOption) error
	Read(ctx context.Context, opts ...ReadOption) error
	Write(ctx context.Context, payload any, opts ...WriteOption) error
	Update(ctx context.Context, payload any, opts ...WriteOption) error
	Delete(ctx context.Context, opts ...DeleteOption) error
	Options() store.Options
	String() string
}

RefinedStore is a go-micro store.Store wrapper to allow SQL and No-SQL database operations.

func NewEmptyStore

func NewEmptyStore() RefinedStore

A RefinedStore mongo constructor. Called automatically by fx and bootstrapper.

func NewMemoryStore

func NewMemoryStore() RefinedStore

A RefinedStore go-micro in-memory constructor. Called automatically by fx and bootstrapper.

func NewMongoStore

func NewMongoStore() RefinedStore

A RefinedStore mongo constructor. Called automatically by fx and bootstrapper.

func NewStorage

func NewStorage(config *config.StorageConfig) RefinedStore

A RefinedStore constructor. Called automatically by fx and bootstrapper.

Returns a RefinedStore compliant implementation based on persistence configuration.

By default - empty adapter

type WriteOption

type WriteOption func(w *WriteOptions)

func WriteExpiry

func WriteExpiry(val time.Time) WriteOption

Sets payload expiration.

func WriteKey

func WriteKey(val string) WriteOption

Sets a filter field name.

func WriteTTL

func WriteTTL(val time.Duration) WriteOption

Sets payload ttl.

func WriteTo

func WriteTo(database, table string) WriteOption

Sets database and database table.

func WriteValue

func WriteValue(val string) WriteOption

Sets a filter field's name's value.

type WriteOptions

type WriteOptions struct {
	Database, Table string
	// Key is the key name to find and update the record (optional).
	Key string
	// Value is the key value to finad and update the record (optional).
	Value string
	// Expiry is the time the record expires.
	Expiry time.Time
	// TTL is the time until the record expires.
	TTL time.Duration
}

WriteOptions configures an individual Write operation If Expiry and TTL are set TTL takes precedence.

Jump to

Keyboard shortcuts

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