Enabling a Storage Provider

The enable storage-provider command configures your workspace to make use of one of the pre-built open source storage adapters in the saas-rs-sdk crate (see the src/storage folder).

Run this command multiple times to enable all the storage providers you intend to support.

Enabling MongoDB Support

To configure your workspace to support MongoDB, perform:

$ saas-rs enable storage-provider MongoDB

You will notice the following files have been changed in your workspace:

crates/
├── config_store/
│   ├── src/
│   │   ├── factory.rs
├── object_store/
│   ├── src/
│   │   ├── factory.rs
Cargo.toml

A closer examination of Cargo.toml will show that the saas-rs-sdk crate has had a mongodb feature flag added, providing your workspace with access to all MongoDB-related adapters and support libraries.

[workspace.dependencies]
saas-rs-sdk = { version = "0.2.7", features = ["...", "mongodb"] }

And a closer examination of config_store/src/factory.rs will show that support has been added for MongoDB URLs:

    Ok(match url.scheme() {
        ...
        "mongodb" | "mongodb+srv" => {
            let index_models_by_bucket = std::collections::HashMap::new(); // TODO
            Arc::new(
                saas_rs_sdk::storage::config_store::adapters::mongodb::MongodbConfigStore::new(
                    url,
                    app_name,
                    belongs_tos_by_bucket,
                    has_manys_by_bucket,
                    index_models_by_bucket,
                )
                .await
                .map_err(|e| Status::internal(e.to_string()))?,
            )
       }
       ...
    })

Perform make and then stage and commit the generated files before you make any further changes:

$ make
cargo fmt --all
cargo build
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.73s

$ git add -A
$ git commit -m "saas-rs enable storage-provider MongoDB"

Enabling Redis Support

To configure your workspace to support Redis, perform:

$ saas-rs enable storage-provider Redis

You will notice the following files have been changed in your workspace:

crates/
├── session_store/
│   ├── src/
│   │   ├── factory.rs
Cargo.toml

A closer examination of Cargo.toml will show that the saas-rs-sdk crate has had a redis feature flag added, providing your workspace with access to all Redis-related adapters and support libraries.

[workspace.dependencies]
saas-rs-sdk = { version = "0.2.7", features = ["...", "redis"] }

And a closer examination of session_store/src/factory.rs will show that support has been added for Redis URLs:

    Ok(match url.scheme() {
        ...
        "redis" | "redis-cluster" | "redis-sentinel" | "redis+unix" => Arc::new(
            saas_rs_sdk::storage::session_store::adapters::redis::RedisSessionStore::new(
                url,
                app_name,
                belongs_tos_by_bucket,
                has_manys_by_bucket,
            )
            .await?,
        ),
        ...
    })

Perform make and then stage and commit the generated files before you make any further changes:

$ make
cargo fmt --all
cargo build
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.73s

$ git add -A
$ git commit -m "saas-rs enable storage-provider Redis"

Show all Storage Providers

To see a list of all the currently supported storage providers, run the command with a help argument like this:

$ saas-rs enable storage-provider --help
Usage: saas-rs enable storage-provider <provider>

Arguments:
  <provider>  The storage provider [possible values: LocalFileSystem, Memory, MongoDB, Postgres, Redis, S3]

Options:
  -h, --help  Print help

©2025 SaaS RS | Website | GitHub | GitLab | Contact