Documentation ¶
Index ¶
- func NewDefaultStateStoreFactory() *build.Factory
- type IStateStore
- type MemoryStateStore
- func (c *MemoryStateStore) Configure(config *cconf.ConfigParams)
- func (c *MemoryStateStore) Delete(correlationId string, key string) interface{}
- func (c *MemoryStateStore) Load(correlationId string, key string) interface{}
- func (c *MemoryStateStore) LoadBulk(correlationId string, keys []string) []*StateValue
- func (c *MemoryStateStore) Save(correlationId string, key string, value interface{}) interface{}
- type NullStateStore
- func (c *NullStateStore) Delete(correlationId string, key string) interface{}
- func (c *NullStateStore) Load(correlationId string, key string) interface{}
- func (c *NullStateStore) LoadBulk(correlationId string, keys []string) []*StateValue
- func (c *NullStateStore) Save(correlationId string, key string, value interface{}) interface{}
- type StateEntry
- type StateValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultStateStoreFactory ¶
Creates IStateStore components by their descriptors. See Factory See IStateStore See MemoryStateStore See NullStateStore
Types ¶
type IStateStore ¶
type IStateStore interface { // Loads state from the store using its key. // If value is missing in the store it returns nil. // // - correlationId (optional) transaction id to trace execution through call chain. // - key a unique state key. // Returns the state value or nil if value wasn't found. Load(correlationId string, key string) interface{} // Loads an array of states from the store using their keys. // // - correlationId (optional) transaction id to trace execution through call chain. // - keys unique state keys. // Returns an array with state values and their corresponding keys. LoadBulk(correlationId string, keys []string) []*StateValue // Saves state into the store. // // - correlationId (optional) transaction id to trace execution through call chain. // - key a unique state key. // - value a state value. // Returns The state that was stored in the store. Save(correlationId string, key string, value interface{}) interface{} // Deletes a state from the store by its key. // // - correlationId (optional) transaction id to trace execution through call chain. // - key a unique value key. Delete(correlationId string, key string) interface{} }
Interface for state storages that are used to store and retrieve transaction states.
type MemoryStateStore ¶
type MemoryStateStore struct {
// contains filtered or unexported fields
}
State store that keeps states in the process memory.
Remember: This implementation is not suitable for synchronization of distributed processes.
### Configuration parameters ###
options:
- timeout: default caching timeout in milliseconds (default: disabled)
### Example ###
store := NewMemoryStateStore(); value := store.Load("123", "key1"); ... store.Save("123", "key1", "ABC");
func NewEmptyMemoryStateStore ¶
func NewEmptyMemoryStateStore() *MemoryStateStore
func (*MemoryStateStore) Configure ¶
func (c *MemoryStateStore) Configure(config *cconf.ConfigParams)
Configures component by passing configuration parameters. - config configuration parameters to be set.
func (*MemoryStateStore) Delete ¶
func (c *MemoryStateStore) Delete(correlationId string, key string) interface{}
Deletes a state from the store by its key.
- correlationId (optional) transaction id to trace execution through call chain. - key a unique state key.
func (*MemoryStateStore) Load ¶
func (c *MemoryStateStore) Load(correlationId string, key string) interface{}
Loads stored value from the store using its key. If value is missing in the store it returns nil.
- correlationId (optional) transaction id to trace execution through call chain. - key a unique state key. Returns the state value or <code>nil</code> if value wasn't found.
func (*MemoryStateStore) LoadBulk ¶
func (c *MemoryStateStore) LoadBulk(correlationId string, keys []string) []*StateValue
Loads an array of states from the store using their keys.
- correlationId (optional) transaction id to trace execution through call chain. - keys unique state keys. Returns an array with state values.
func (*MemoryStateStore) Save ¶
func (c *MemoryStateStore) Save(correlationId string, key string, value interface{}) interface{}
Saves state into the store
- correlationId (optional) transaction id to trace execution through call chain. - key a unique state key. - value a state value to store. Returns The value that was stored in the cache.
type NullStateStore ¶
type NullStateStore struct { }
Dummy state store implementation that doesn't do anything.
It can be used in testing or in situations when state management is not required but shall be disabled.
func NewEmptyNullStateStore ¶
func NewEmptyNullStateStore() *NullStateStore
func (*NullStateStore) Delete ¶
func (c *NullStateStore) Delete(correlationId string, key string) interface{}
Deletes a state from the store by its key.
- correlationId (optional) transaction id to trace execution through call chain. - key a unique value key.
func (*NullStateStore) Load ¶
func (c *NullStateStore) Load(correlationId string, key string) interface{}
Loads state from the store using its key. If value is missing in the stored it returns nil.
- correlationId (optional) transaction id to trace execution through call chain. - key a unique state key. Returns the state value or nil if value wasn't found.
func (*NullStateStore) LoadBulk ¶
func (c *NullStateStore) LoadBulk(correlationId string, keys []string) []*StateValue
Loads an array of states from the store using their keys.
- correlationId (optional) transaction id to trace execution through call chain. - keys unique state keys. Returns an array with state values and their corresponding keys.
func (*NullStateStore) Save ¶
func (c *NullStateStore) Save(correlationId string, key string, value interface{}) interface{}
Saves state into the store.
- correlationId (optional) transaction id to trace execution through call chain. - key a unique state key. - value a state value. Returns The state that was stored in the store.
type StateEntry ¶
type StateEntry struct {
// contains filtered or unexported fields
}
Data object to store state values with their keys used by [[MemoryStateEntry]]
func NewStateEntry ¶
func NewStateEntry(key string, value interface{}) *StateEntry
NewStateEntry method creates a new instance of the state entry and assigns its values. - key a unique key to locate the value. - value a value to be stored.
func (*StateEntry) GetKey ¶
func (c *StateEntry) GetKey() string
GetKey method gets the key to locate the state value. Returns the value key.
func (*StateEntry) GetLastUpdateTime ¶
func (c *StateEntry) GetLastUpdateTime() int64
GetLastUpdateTime method gets the last update time. Returns the timestamp when the value ware stored.
func (*StateEntry) GetValue ¶
func (c *StateEntry) GetValue() interface{}
GetValue method gets the sstate value. Returns the value object.
func (*StateEntry) SetValue ¶
func (c *StateEntry) SetValue(value interface{})
SetValue method sets a new state value. - value a new cached value.
type StateValue ¶
type StateValue struct { Key string `json:"key" bson:"key"` // A unique state key Value interface{} `json:"value" bson:"value"` // A stored state value }
A data object that holds a retrieved state value with its key.