Objectstore Client
The client is used to interface with the Objectstore backend. It handles responsibilities like transparent compression, and making sure that uploads and downloads are done as efficiently as possible.
Quick Start
use ;
async
Core Concepts
Usecases and Scopes
A [Usecase] represents a server-side namespace with its own configuration defaults.
Within a Usecase, [Scope]s provide further isolation — typically keyed by organization
and project IDs. A [Session] ties a Client to a specific Usecase + Scope for operations.
Scope components form a hierarchical path, so their order matters:
org=42/project=1337 and project=1337/org=42 are different scopes. The convenience
method [Usecase::for_project] pushes org then project in the recommended order.
// Scope with org and project (recommended first components)
let session = new
.for_project
.session?;
// Additional components are appended after org/project
let session = new
.for_project
.push
.session?;
Expiration
Objects can expire automatically using Time To Live (from creation) or Time To Idle
(from last access). Defaults are set at the Usecase level and can be overridden per-upload.
Without an expiration policy, objects use Manual expiration (no auto-deletion).
We strongly recommend setting an expiration policy on every Usecase to prevent
unbounded storage growth. Choose TimeToIdle for cache-like data that should stay
alive while actively used, or TimeToLive for data with a fixed retention period.
use Duration;
use ExpirationPolicy;
// Set default expiration on the Usecase
new
.with_expiration_policy;
// Override per-upload
session.put
.expiration_policy
.send.await?;
Origin Tracking
We encourage setting the origin on every upload to track where the payload was
originally obtained from (e.g., the IP address of the Sentry SDK or CLI). This is
optional but helps with auditing and debugging.
session.put.origin.send.await?;
Compression
Uploads are compressed with Zstd by default. Downloads are transparently decompressed.
You can override compression per-upload for pre-compressed or uncompressible data.
See [Compression] for available options.
use Compression;
session.put
.compression // disable compression
.send.await?;
To receive a compressed payload without decompressing it — for example, when forwarding
to a system that accepts zstd natively — use accept_encoding on the get request:
use Compression;
// Returns zstd-compressed bytes; metadata.compression is preserved.
let response = session.get
.accept_encoding
.send.await?
.expect;
assert_eq!;
let compressed_bytes = response.payload.await?;
Custom Metadata
Arbitrary key-value pairs can be attached to objects and retrieved on download.
session.put
.append_metadata
.send.await?;
Many API
The Many API allows you to enqueue multiple requests that the client can execute using Objectstore's batch endpoint, minimizing network overhead.
send() returns a stream of the results of each operation. Results are not guaranteed to be in the order they were originally enqueued in.
use StreamExt as _;
use ;
async
If you don't need to inspect individual operation results and just want to fail if any error occurs,
use error_for_failures which drains the stream and returns all errors at once:
session
.many
.push
.push
.push
.send
.await
.error_for_failures
.await
.map_err?;
Authentication
If your Objectstore instance enforces authorization, you must configure authentication
via [ClientBuilder::token]. It accepts either:
- A [
TokenGenerator] — for internal services that have access to an EdDSA keypair. The generator signs a fresh JWT for each request, scoped to the specific usecase and scope being accessed. - A
String/&str— a pre-signed JWT, used as-is for every request. Use this for external services that receive a token from another source.
use ;
// Option 1: Internal service with a keypair
let client = builder
.token
.build?;
// Option 2: External service with a pre-signed JWT
// Use TokenGenerator::sign() to obtain a static token from an internal
// service, then pass it to the external consumer:
let scope = new.for_project;
let token = new?.sign?;
let client = builder
.token
.build?;
Configuration
In production, store the [Client] and [Usecase] in a static and reuse them.
The following shows all available builder options with their defaults:
use Duration;
use LazyLock;
use ;
static CLIENT: = new;
static ATTACHMENTS: = new;
async
See [ClientBuilder] for all available options, including authentication via
[TokenGenerator].
See the API docs for full reference documentation.
License
Like Sentry, Objectstore is licensed under the FSL. See the LICENSE.md file
and this blog post
for more information.