Buckets.Cloud.Dynamic (buckets v1.0.0-rc.1)

Dynamic configuration management for Cloud modules.

This module provides functions for managing runtime configuration changes, allowing Cloud modules to switch between different adapters and configurations on a per-process basis, similar to Ecto.Repo.put_dynamic_repo/1.

Usage

These functions are automatically available on Cloud modules that use Buckets.Cloud. You typically don't need to call this module directly.

Process-Local Configuration

MyApp.Cloud.put_dynamic_config([
  adapter: Buckets.Adapters.GCS,
  bucket: "tenant-bucket",
  service_account_credentials: credentials
])

Scoped Configuration

MyApp.Cloud.with_config(config, fn ->
  MyApp.Cloud.insert("file.pdf")
end)

Auth Server Management

For adapters that need background processes (like GCS auth servers), these are automatically started and cached per-process as needed through the adapter's prepare_dynamic_config/1 callback.

Summary

Functions

Gets the current configuration for the given cloud module.

Sets dynamic configuration for the current process.

Executes a function with a specific configuration.

Functions

Link to this function

config(cloud_module, otp_app)

Gets the current configuration for the given cloud module.

Checks the process dictionary first for dynamic config, falls back to static config.

Link to this function

put_dynamic_config(cloud_module, config)

Sets dynamic configuration for the current process.

This configuration will be used for all subsequent operations in this process until changed or deleted.

Link to this function

with_config(cloud_module, config, fun)

Executes a function with a specific configuration.

The configuration is only active during the execution of the function. Previous configuration is restored afterwards.