pdk-data-storage-lib 0.0.0-alpha.3

PDK
Documentation
pdk-data-storage-lib-0.0.0-alpha.3 has been yanked.

PDK Data Storage Library   Latest Version data_storage_lib msrv

PDK Data Storage Lib is a library that provides a simple interface for storing and retrieving data for your Flex Gateway custom policies.


You may be looking for:

Note: To make use of the remote mode of the data storage your Flex Gateway must have Shared Storage configured.

pdk-data-storage-lib in action

[dependencies]

# This package is included as a transitive depdendency of the pdk crate.
pdk = { version = "1.6"}
use pdk::data_storage::{DataStorage, DataStorageBuilder, StoreMode};
use pdk::hl::*;
use pdk::logger;

async fn request_filter(
    state: RequestHeadersState,
    storage: &impl DataStorage,
) -> Flow<()> {
    // Your custom policy code.
}

#[entrypoint]
async fn configure(
    launcher: Launcher,
    store_builder: DataStorageBuilder,
) -> anyhow::Result<()> {

    let local = store_builder.local(namespace);
    launcher
        .launch(on_request(|request| {
            request_filter(request, &local)
        }))
        .await?;
    Ok(())
}

License