Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[workspace]
resolver = "3"
members = ["client", "proto-codegen", "server", "service", "stresstest"]
default-members = ["server"]

[profile.dev]
# Debug information slows down the build and increases caches in the
# target folder, but we don't require stack traces in most cases.
debug = false

[profile.dev-debug]
# A version of the dev profile with debug information enabled, for e.g. local
# debugging.
inherits = "dev"
debug = true

[profile.release]
# In release, however, we do want full debug information to report
# panic and error stack traces to Sentry.
debug = true
lto = "thin"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@ It currently contains the following pieces:
as well as external clients.
- `service`: The core blob storage primitives.
- `stresstest`: A stresstest binary that can run various workloads against a storage backend.

## Development

Ensure `protoc` and the latest stable Rust toolchain are installed on your machine. Then, run the server with:

```sh
cargo run
```

To run tests:

```sh
cargo test --workspace --all-features
```

We recommend using Rust Analyzer and clippy.
3 changes: 3 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ version = "0.1.0"
edition = "2024"

[dependencies]
tokio = { version = "1.45.1", features = ["full"] }
tonic = { version = "0.13.1" }
proto-codegen = { path = "../proto-codegen" }
service = { path = "../service" }
45 changes: 43 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@
//! storage layer as both a `gRPC` service for use by the `client`, as well as
//! an `HTTP` layer which can serve files directly to *external clients*.

fn main() {
println!("Hello, world!");
use proto_codegen::storage::{AllocateBlobRequest, AllocateBlobResponse, StorageId};
use tonic::{Request, Response, Status, transport::Server};

use proto_codegen::storage::storage_server::{Storage, StorageServer};

#[derive(Default)]
pub struct MockStorage {}

#[tonic::async_trait]
impl Storage for MockStorage {
async fn put_blob(
&self,
request: Request<AllocateBlobRequest>,
) -> Result<Response<AllocateBlobResponse>, Status> {
// Here you would handle the blob upload logic.
println!("Received a blob upload request: {:?}", request);

let storage_id = StorageId {
id: "usecase/4711.0001".to_owned().into_bytes(),
};

let response = AllocateBlobResponse {
id: Some(storage_id),
signed_put_url: "https://localhost:5000/mocked-upload".to_owned(),
};

Ok(Response::new(response))
}
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "0.0.0.0:50051".parse().unwrap();
let greeter = MockStorage::default();

println!("Server listening on {addr}");

Server::builder()
.add_service(StorageServer::new(greeter))
.serve(addr)
.await?;

Ok(())
}