glut

package
v0.34.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v0.33.1

func Delete(ctx context.Context, store *coal.Store, value Value) (bool, error)

Delete will remove the specified value from the store. This method will ignore any locks held on the value.

func DeleteLocked added in v0.33.1

func DeleteLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)

DeleteLocked will delete the specified value only if it is locked.

func Ensure added in v0.33.1

func Ensure(ctx context.Context, store *coal.Store, value Value) (bool, error)

Ensure will write the specified value to the store if it does not exist already. It will return if a new value has been created.

func Get

func Get(ctx context.Context, store *coal.Store, value Value) (bool, error)

Get will load the contents of the specified value. It will also return whether the value exists at all.

func GetDeadline added in v0.33.1

func GetDeadline(value Value) (*time.Time, error)

GetDeadline will get the deadline of a value.

func GetKey added in v0.28.0

func GetKey(value Value) (string, error)

GetKey will get the key of a value.

func GetLocked

func GetLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)

GetLocked will load the contents of the specified value only if it is locked.

func Lock

func Lock(ctx context.Context, store *coal.Store, value Value, timeout time.Duration) (bool, error)

Lock will lock and read the specified value. Lock may create a new value in the process and lock it right away. It will also update the deadline of the value if a time to live is set.

func Mutate added in v0.33.1

func Mutate(ctx context.Context, store *coal.Store, value Value, fn func(bool) error) error

Mutate will load the specified value, run the callback and on success write the value back. This method will ignore any locks held on the value.

func MutateLocked added in v0.33.1

func MutateLocked(ctx context.Context, store *coal.Store, value Value, fn func(bool) error) error

MutateLocked will load the specified value, run the callback and on success write the value back.

func Set

func Set(ctx context.Context, store *coal.Store, value Value) (bool, error)

Set will write the specified value to the store and overwrite any existing data. It will return if a new value has been created in the process. This method will ignore any locks held on the value.

func SetLocked

func SetLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)

SetLocked will update the specified value only if it is locked. It will als update the deadline of the value if a time to live is set.

func Unlock

func Unlock(ctx context.Context, store *coal.Store, value Value) (bool, error)

Unlock will unlock the specified value only if it is locked. It will also update the deadline of the value if a time to live is set.

Types

type Base added in v0.28.0

type Base struct {
	// The token used for value locking.
	Token coal.ID
}

Base can be embedded in a struct to turn it into a value.

func (*Base) GetAccessor added in v0.28.0

func (b *Base) GetAccessor(v interface{}) *stick.Accessor

GetAccessor implements the Value interface.

func (*Base) GetBase added in v0.28.0

func (b *Base) GetBase() *Base

GetBase implements the Value interface.

type ExtendedValue added in v0.28.0

type ExtendedValue interface {
	Value
	GetExtension() string
}

ExtendedValue is a value that can extends its key.

type Meta added in v0.28.0

type Meta struct {
	// The values type.
	Type reflect.Type

	// The values key.
	Key string

	// The values time to live.
	TTL time.Duration

	// The used transfer coding.
	Coding stick.Coding

	// The accessor.
	Accessor *stick.Accessor
}

Meta contains meta information about a value.

func GetMeta added in v0.28.0

func GetMeta(value Value) *Meta

GetMeta will parse the values "glut" tag on the embedded glut.Base struct and return the meta object.

type Model added in v0.28.0

type Model struct {
	coal.Base `json:"-" bson:",inline" coal:"values"`

	// The key of the value.
	Key string `json:"key"`

	// The content of the value.
	Data stick.Map `json:"data"`

	// The time after the value can be deleted.
	Deadline *time.Time `json:"deadline"`

	// The time until the value is locked.
	Locked *time.Time `json:"locked"`

	// The token used to lock the value.
	Token *coal.ID `json:"token"`
}

Model stores an encoded value.

func (*Model) Validate added in v0.28.0

func (m *Model) Validate() error

Validate will validate the model.

type RestrictedValue added in v0.33.1

type RestrictedValue interface {
	Value
	GetDeadline() *time.Time
}

RestrictedValue is value that can defines its deadline.

type Value

type Value interface {
	Validate() error
	GetBase() *Base
	GetAccessor(interface{}) *stick.Accessor
}

Value is a structure used to encode a value.

Jump to

Keyboard shortcuts

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