pub struct DataStorageBuilder { /* private fields */ }Expand description
Builder for creating data storage instances.
Provides methods to create local and distributed storage instances with configurable settings. The builder pattern allows for flexible configuration of storage behavior.
§Examples
// Create a local storage instance
let local_storage = builder.local("my-local-storage");
// Create a distributed storage instance with 60-second TTL
let remote_storage = builder.remote("my-remote-storage", 60000);Implementations§
Source§impl DataStorageBuilder
impl DataStorageBuilder
Indicates that storage should not be isolated to a single policy. The resulting state will be shared across policy instances that use the same storage ID.
Sourcepub fn local<T: Into<String>>(&self, key: T) -> LocalDataStorage
pub fn local<T: Into<String>>(&self, key: T) -> LocalDataStorage
Creates a local data storage instance identified by the key.
Sourcepub fn remote<T: Into<String>>(
&self,
key: T,
ttl_millis: u32,
) -> RemoteDataStorage
pub fn remote<T: Into<String>>( &self, key: T, ttl_millis: u32, ) -> RemoteDataStorage
Creates a distributed data storage instance identified by the provided key and ttl in milliseconds.
Note: To make use of the remote mode of the data storage your Flex Gateway must have Shared Storage configured.
§Panics
Panics if distributed storage is not available in the current context. Ensure that distributed storage is properly configured before calling this method.
Trait Implementations§
Source§impl FromContext<ConfigureContext> for DataStorageBuilder
DataStorageBuilder can be injected in your configuration function.
impl FromContext<ConfigureContext> for DataStorageBuilder
DataStorageBuilder can be injected in your configuration function.
#[entrypoint]
async fn configure(
launcher: Launcher,
store_builder: DataStorageBuilder,
Configuration(configuration): Configuration,
) -> anyhow::Result<()> {
}