common

package
v0.0.0-...-58c0a64 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBasePrefix

func GetBasePrefix() string

GetBasePrefix returns the prefix

Types

type BaseModel

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

BaseModel implements basic model functionality

func (*BaseModel) GetVersion

func (b *BaseModel) GetVersion() string

GetVersion Base implementation of get version. Default version is "0".

func (*BaseModel) SetVersion

func (b *BaseModel) SetVersion(version string)

SetVersion Base implementation of set version

type BaseRepo

type BaseRepo struct {
	Registry registry.IRegistry
}

BaseRepo implements base repo methods

func (BaseRepo) Acquire

func (r BaseRepo) Acquire(ctx context.Context, m IModel, sessionID string) error

Acquire puts the model in the registry with a attempt to lock using sessionID

func (BaseRepo) Delete

func (r BaseRepo) Delete(ctx context.Context, m IModel) error

Delete deletes all keys under a model key

func (BaseRepo) DeleteTree

func (r BaseRepo) DeleteTree(ctx context.Context, key string) error

DeleteTree deletes all keys under a prefix

func (BaseRepo) Exists

func (r BaseRepo) Exists(ctx context.Context, key string) (bool, error)

Exists to check if the key exists in the registry

func (BaseRepo) Get

func (r BaseRepo) Get(ctx context.Context, key string, m IModel) error

Get populates m with value corresponding to key

func (BaseRepo) ListKeys

func (r BaseRepo) ListKeys(ctx context.Context, prefix string) ([]string, error)

ListKeys populates keys with key list corresponding to prefix

func (BaseRepo) Save

func (r BaseRepo) Save(ctx context.Context, m IModel) error

Save puts the model in the registry

type IModel

type IModel interface {
	// Key returns the key to store the model against
	Key() string
	// Prefix returns the key prefix used by the module
	Prefix() string
	// Returns the version of the saved model in the registry. Version changes for every update.
	GetVersion() string
	//Sets the version of the saved model from the registry. Never to be used by business logic.
	SetVersion(version string)
}

IModel interface which all models should implement

type IRepo

type IRepo interface {
	Save(ctx context.Context, m IModel) error
	Acquire(ctx context.Context, m IModel, sessionID string) error
	Exists(ctx context.Context, key string) (bool, error)
	Delete(ctx context.Context, m IModel) error
	DeleteTree(ctx context.Context, key string) error
	Get(ctx context.Context, key string, m IModel) error
	ListKeys(ctx context.Context, prefix string) ([]string, error)
}

IRepo is an interface over common repo functionality

Jump to

Keyboard shortcuts

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