Skip to content

Commit e683ddf

Browse files
authored
meta: Add cargo metadata and a client readme (#154)
Adds metadata to all crates in the workspace, most notably setting the `publish` flag on all crates. The client is the only crate that will be published at this point. We also set the minimum Rust version of the client library to 1.89.0, the second latest version at the time of writing. This additionally configures clippy to lint at that level. We will be bumping this version only as needed, so we do not force downstream projects to update their toolchain prematurely. This also adds a _README.md_ to the client and adds a usage example to the top-level client library docstring. To simplify handling of payloads, we introduce a `.payload()` and `.text()` helper method on the `GetResult` type.
1 parent fa86d14 commit e683ddf

9 files changed

Lines changed: 98 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,9 @@ cargo run --release -p stresstest -- -c stresstest/config/example.yaml
191191
Similar to the objectstore server, you can find example configuration files in
192192
the `config` subfolder. Copy and save your own files there, as they will not be
193193
tracked by git.
194+
195+
## License
196+
197+
Like Sentry, Objectstore is licensed under the FSL. See the `LICENSE.md` file
198+
and [this blog post](https://blog.sentry.io/introducing-the-functional-source-license-freedom-without-free-riding/)
199+
for more information.

objectstore-client/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
[package]
22
name = "objectstore-client"
3+
authors = ["Sentry <oss@sentry.io>"]
4+
description = "Client SDK for Objectstore, the Sentry object storage platform"
5+
homepage = "https://getsentry.github.io/objectstore/"
6+
repository = "https://github.com/getsentry/objectstore"
7+
license-file = "../LICENSE.md"
38
version = "0.1.0"
49
edition = "2024"
10+
rust-version = "1.89"
11+
publish = true
512

613
[dependencies]
714
anyhow = { workspace = true }

objectstore-client/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Objectstore Client
2+
3+
The client is used to interface with the objectstore backend. It handles
4+
responsibilities like transparent compression, and making sure that uploads and
5+
downloads are done as efficiently as possible.
6+
7+
## Usage
8+
9+
```rust
10+
use objectstore_client::ClientBuilder;
11+
12+
let client = ClientBuilder::new("http://localhost:8888/", "my-usecase")?
13+
.for_organization(42);
14+
15+
let id = client.put("hello world").send().await?;
16+
let object = client.get(&id.key).send().await?.expect("object to exist");
17+
assert_eq!(object.payload().await?, "hello world");
18+
```
19+
20+
## License
21+
22+
Like Sentry, Objectstore is licensed under the FSL. See the `LICENSE.md` file
23+
and [this blog post](https://blog.sentry.io/introducing-the-functional-source-license-freedom-without-free-riding/)
24+
for more information.

objectstore-client/src/get.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{fmt, io};
22

33
use async_compression::tokio::bufread::ZstdDecoder;
4+
use bytes::BytesMut;
45
use futures_util::{StreamExt, TryStreamExt};
56
use objectstore_types::Metadata;
67
use reqwest::StatusCode;
@@ -19,6 +20,21 @@ pub struct GetResult {
1920
/// The response stream.
2021
pub stream: ClientStream,
2122
}
23+
24+
impl GetResult {
25+
/// Loads the object payload fully into memory.
26+
pub async fn payload(self) -> anyhow::Result<bytes::Bytes> {
27+
let bytes: BytesMut = self.stream.try_collect().await?;
28+
Ok(bytes.freeze())
29+
}
30+
31+
/// Loads the object payload fully into memory and interprets it as UTF-8 text.
32+
pub async fn text(self) -> anyhow::Result<String> {
33+
let bytes = self.payload().await?;
34+
Ok(String::from_utf8(bytes.to_vec())?)
35+
}
36+
}
37+
2238
impl fmt::Debug for GetResult {
2339
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2440
f.debug_struct("GetResult")

objectstore-client/src/lib.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
//! The Storage Client
1+
//! # Objectstore Client
22
//!
3-
//! The Client is used to interface with the objectstore backend.
4-
//! It handles responsibilities like transparent compression, and making sure that
5-
//! uploads and downloads are done as efficiently as possible.
3+
//! The client is used to interface with the objectstore backend. It handles responsibilities like
4+
//! transparent compression, and making sure that uploads and downloads are done as efficiently as
5+
//! possible.
6+
//!
7+
//! ## Usage
8+
//!
9+
//! ```no_run
10+
//! use objectstore_client::ClientBuilder;
11+
//!
12+
//! #[tokio::main]
13+
//! # async fn main() -> anyhow::Result<()> {
14+
//! let client = ClientBuilder::new("http://localhost:8888/", "my-usecase")?
15+
//! .for_organization(42);
16+
//!
17+
//! let id = client.put("hello world").send().await?;
18+
//! let object = client.get(&id.key).send().await?.expect("object to exist");
19+
//! assert_eq!(object.payload().await?, "hello world");
20+
//! # Ok(())
21+
//! # }
22+
//! ```
623
#![warn(missing_docs)]
724
#![warn(missing_debug_implementations)]
825

objectstore-server/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
[package]
22
name = "objectstore-server"
3+
authors = ["Sentry <oss@sentry.io>"]
4+
description = "Web server application of Objectstore, the Sentry object storage platform"
5+
homepage = "https://getsentry.github.io/objectstore/"
6+
repository = "https://github.com/getsentry/objectstore"
7+
license-file = "../LICENSE.md"
38
version = "0.1.0"
49
edition = "2024"
510
build = "build.rs"
11+
publish = false
612

713
[dependencies]
814
anyhow = { workspace = true }

objectstore-service/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
[package]
22
name = "objectstore-service"
3+
authors = ["Sentry <oss@sentry.io>"]
4+
description = "Storage and backend logic of Objectstore, the Sentry object storage platform"
5+
homepage = "https://getsentry.github.io/objectstore/"
6+
repository = "https://github.com/getsentry/objectstore"
7+
license-file = "../LICENSE.md"
38
version = "0.1.0"
49
edition = "2024"
10+
publish = false
511

612
[dependencies]
713
anyhow = { workspace = true }

objectstore-types/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
[package]
22
name = "objectstore-types"
3+
authors = ["Sentry <oss@sentry.io>"]
4+
description = "Shared types for the Objectstore client and server"
5+
homepage = "https://getsentry.github.io/objectstore/"
6+
repository = "https://github.com/getsentry/objectstore"
7+
license-file = "../LICENSE.md"
38
version = "0.1.0"
49
edition = "2024"
10+
publish = false
511

612
[dependencies]
713
anyhow = { workspace = true }

stresstest/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
[package]
22
name = "stresstest"
3+
authors = ["Sentry <oss@sentry.io>"]
4+
description = "Tool for generating file storage load against Objectstore servers"
5+
homepage = "https://getsentry.github.io/objectstore/"
6+
repository = "https://github.com/getsentry/objectstore"
7+
license-file = "../LICENSE.md"
38
version = "0.1.0"
49
edition = "2024"
10+
publish = false
511

612
[dependencies]
713
anyhow = { workspace = true }

0 commit comments

Comments
 (0)