pip_services3_components.state package
Submodules
- pip_services3_components.state.DefaultStateStoreFactory module
 - pip_services3_components.state.IStateStore module
 - pip_services3_components.state.MemoryStateStore module
 - pip_services3_components.state.NullStateStore module
 - pip_services3_components.state.StateEntry module
 - pip_services3_components.state.StateValue module
 
Module contents
- 
class 
pip_services3_components.state.DefaultStateStoreFactory Bases:
pip_services3_components.build.Factory.FactoryCreates
IStateStorecomponents by their descriptors.See:
Factory,IStateStore,MemoryStateStore,NullStateStore- 
MemoryStateStoreDescriptor= <pip_services3_commons.refer.Descriptor.Descriptor object> 
- 
NullStateStoreDescriptor= <pip_services3_commons.refer.Descriptor.Descriptor object> 
- 
descriptor= <pip_services3_commons.refer.Descriptor.Descriptor object> 
- 
 
- 
class 
pip_services3_components.state.IStateStore Bases:
abc.ABCInterface for state storages that are used to store and retrieve transaction states.
- 
abstract 
delete(correlation_id: Optional[str], key: str) → Any Deletes a state from the store by its key.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique value key.
- Returns
 deleted item
- 
abstract 
load(correlation_id: Optional[str], key: str) → Any Loads state from the store using its key. If value is missing in the store it returns None.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique state key.
- Returns
 the state value or None if value wasn’t found.
- 
abstract 
load_bulk(correlation_id: Optional[str], keys: List[str]) → List[pip_services3_components.state.StateValue.StateValue] Loads an array of states from the store using their keys.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
keys – unique state keys.
- Returns
 an array with state values and their corresponding keys.
- 
abstract 
 
- 
class 
pip_services3_components.state.MemoryStateStore Bases:
pip_services3_components.state.IStateStore.IStateStore,pip_services3_commons.config.IReconfigurable.IReconfigurableState 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)
See:
ICacheExample:
store = MemoryStateStore() value = store.load("123", "key1") ... store.save("123", "key1", "ABC")
- 
configure(config: pip_services3_commons.config.ConfigParams.ConfigParams) Configures component by passing configuration parameters.
- Parameters
 config – configuration parameters to be set.
- 
delete(correlation_id: Optional[str], key: str) → Any Deletes a state from the store by its key.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique state key.
- Returns
 deleted item
- 
load(correlation_id: Optional[str], key: str) → Any Loads stored value from the store using its key. If value is missing in the store it returns None.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique state key.
- Returns
 the state value or None if value wasn’t found.
- 
load_bulk(correlation_id: Optional[str], keys: List[str]) → List[pip_services3_components.state.StateValue.StateValue] Loads an array of states from the store using their keys.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
keys – unique state keys.
- Returns
 an array with state values.
- 
 
- 
class 
pip_services3_components.state.NullStateStore Bases:
pip_services3_components.state.IStateStore.IStateStoreDummy 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.
See:
ICache- 
delete(correlation_id: Optional[str], key: str) → Any Deletes a state from the store by its key.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique value key.
- Returns
 deleted item
- 
load(correlation_id: Optional[str], key: str) → Any Loads state from the store using its key. If value is missing in the stored it returns None.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique state key.
- Returns
 the state value or None if value wasn’t found.
- 
load_bulk(correlation_id: Optional[str], keys: List[str]) → List[pip_services3_components.state.StateValue.StateValue] Loads an array of states from the store using their keys.
- Parameters
 correlation_id – (optional) transaction id to trace execution through call chain.
keys – unique state keys.
- Returns
 an array with state values and their corresponding keys.
- 
 
- 
class 
pip_services3_components.state.StateEntry(key: str, value: Any) Bases:
objectData object to store state values with their keys used by
MemoryStateStore- 
get_last_update_time() → int Gets the last update time.
- Returns
 the timestamp when the value ware stored.
- 
get_value() Gets the sstate value.
- Returns
 the value object.
- 
set_value(value: Any) Sets a new state value.
- Parameters
 value – a new cached value.
-