Documentation
¶
Index ¶
- func AddValueIndexes(catalog *coal.Catalog, removeAfter time.Duration)
- func Del(store *coal.Store, component, name string) (bool, error)
- func DelLocked(store *coal.Store, component, name string, token coal.ID) (bool, error)
- func Get(store *coal.Store, component, name string) (coal.Map, bool, error)
- func GetLocked(store *coal.Store, component, name string, token coal.ID) (coal.Map, bool, error)
- func Lock(store *coal.Store, component, name string, token coal.ID, ...) (bool, error)
- func Mut(store *coal.Store, component, name string, ttl time.Duration, ...) error
- func MutLocked(store *coal.Store, component, name string, token coal.ID, ...) error
- func Set(store *coal.Store, component, name string, data coal.Map, ttl time.Duration) (bool, error)
- func SetLocked(store *coal.Store, component, name string, data coal.Map, token coal.ID) (bool, error)
- func Unlock(store *coal.Store, component, name string, token coal.ID, ttl time.Duration) (bool, error)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddValueIndexes ¶
AddValueIndexes will add value indexes to the specified catalog. If removeAfter is values are automatically removed when their deadline timestamp falls behind the specified duration.
func Del ¶
Del will remove the specified value from the store. This method will ignore any locks held on the value.
func DelLocked ¶
DelLocked will update the specified value only if the value is locked by the specified token.
func Get ¶
Get will load the contents of the value with the specified name. It will also return whether the value exists at all.
func GetLocked ¶
GetLocked will load the contents of the value with the specified name only if the value is locked by the specified token.
func Lock ¶
func Lock(store *coal.Store, component, name string, token coal.ID, timeout, ttl time.Duration) (bool, error)
Lock will lock the specified value using the specified token for the specified duration. Lock may create a new value in the process and lock it right away. It will also update the deadline of the value if TTL is set.
func Mut ¶ added in v0.26.0
func Mut(store *coal.Store, component, name string, ttl time.Duration, fn func(bool, coal.Map) (coal.Map, error)) error
Mut 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 MutLocked ¶ added in v0.26.0
func MutLocked(store *coal.Store, component, name string, token coal.ID, fn func(bool, coal.Map) (coal.Map, error)) error
MutLocked will load the specified value, run the callback and on success write the value back.
func Set ¶
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.
Types ¶
type Value ¶
type Value struct {
coal.Base `json:"-" bson:",inline" coal:"values"`
// The component managing the value.
Component string `json:"component"`
// The name of the value e.g. "my-value".
Name string `json:"name"`
// The content of the value.
Data coal.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"`
}
Value stores an arbitrary value.