Skip to content

Commit

Permalink
Implement streamed responses (#31)
Browse files Browse the repository at this point in the history
* feat: add futures dependency and refactor services

- Added `futures` dependency to `Cargo.toml` and `Cargo.lock`.
- Updated README.md to correct service start commands.
- Renamed `build.proto` to `command.proto` and updated package and service definitions.
- Modified `package.proto` to support streaming responses.
- Updated `build.rs` to compile new proto files.
- Refactored example Rust project to use `tokio-stream` and updated dependencies.
- Updated `vorpal.rs` to use `CommandServiceClient` and handle streaming responses.
- Modified `flake.nix` to update build inputs and process commands.
- Cleaned up `justfile` to remove redundant clean commands.
- Refactored `main.rs` to use `clap` for command-line parsing and added subcommands for keys and services.
- Removed `command/mod.rs` and integrated its functionality into `main.rs`.
- Updated `lib.rs` to include new proto modules and removed `command` module.
- Renamed `notary::init` to `notary::check_keys`.
- Refactored `run_build.rs` and `run_prepare.rs` to support streaming responses and improved error handling.
- Updated `service.rs` to use new streaming response types.
- Refactored `proxy` service to use `CommandServiceServer` and updated package handling.
- Improved logging and error handling throughout the codebase.

* refactor(vorpal): simplify hash assignment in package source

Simplified the assignment of the hash value in the PackageSource struct by removing unnecessary line breaks. This change improves code readability without altering functionality.

* fix: improve code quality and enforce stricter linting

- Updated `justfile` to enforce stricter linting by adding `-D warnings` to `cargo clippy`.
- Simplified boolean field initialization in `run_build.rs` by removing redundant field name.
- Replaced `format!` with `to_string` for `package_log` in `mod.rs` to improve code readability and performance.

* chore: update dependencies

- Update `backtrace` from 0.3.72 to 0.3.73
- Update `clap` and `clap_builder` from 4.5.6 to 4.5.7
- Add new package `displaydoc` version 0.2.4
- Update `git2` from 0.18.3 to 0.19.0
- Update `http-body-util` from 0.1.1 to 0.1.2
- Update `httparse` from 1.8.0 to 1.9.3
- Add new packages `icu_collections`, `icu_locid`, `icu_locid_transform`, `icu_locid_transform_data`, `icu_normalizer`, `icu_normalizer_data`, `icu_properties`, `icu_properties_data`, `icu_provider`, `icu_provider_macros` all version 1.5.0
- Update `idna` from 0.5.0 to 1.0.0
- Update `libgit2-sys` from 0.16.2+1.7.2 to 0.17.0+1.8.1
- Add new package `litemap` version 0.7.3
- Update `memchr` from 2.7.2 to 2.7.4
- Update `object` from 0.35.0 to 0.36.0
- Update `redox_syscall` from 0.5.1 to 0.5.2
- Add new package `stable_deref_trait` version 1.2.0
- Add new package `synstructure` version 0.13.1
- Replace `tinyvec` and `tinyvec_macros` with `tinystr` version 0.7.6
- Update `url` from 2.5.0 to 2.5.1
- Add new packages `utf16_iter` version 1.0.5 and `utf8_iter` version 1.0.4
- Add new packages `write16` version 1.0.0 and `writeable` version 0.5.5
- Add new packages `yoke` version 0.7.4 and `yoke-derive` version 0.7.4
- Add new packages `zerofrom` version 0.1.4 and `zerofrom-derive` version 0.1.4
- Add new package `zerovec` version 0.10.2 and `zerovec-derive` version 0.10.2

Update `flake.lock`:
- Update `nixpkgs` to `e9ee548d90ff586a6471b4ae80ae9cfcbceb3420`
- Update `process-compose-flake` to `9344fac44edced4c686721686a6ad904d067c546`
- Update `rust-overlay` to `7c2d603cb67c974ef8c5cfee1150060dbb299e04`

* chore(dependencies): update multiple dependencies

- Update `backtrace` from 0.3.72 to 0.3.73
- Add new package `cfb` version 0.7.3
- Update `clap` and `clap_builder` from 4.5.6 to 4.5.7
- Add new package `displaydoc` version 0.2.4
- Update `git2` from 0.18.3 to 0.19.0
- Update `http-body-util` from 0.1.1 to 0.1.2
- Update `httparse` from 1.8.0 to 1.9.3
- Add new packages related to `icu` (icu_collections, icu_locid, icu_locid_transform, icu_locid_transform_data, icu_normalizer, icu_normalizer_data, icu_properties, icu_properties_data, icu_provider, icu_provider_macros) all version 1.5.0
- Update `idna` from 0.5.0 to 1.0.0
- Update `infer` from 0.3.7 to 0.16.0
- Update `libgit2-sys` from 0.16.2+1.7.2 to 0.17.0+1.8.1
- Add new package `litemap` version 0.7.3
- Update `memchr` from 2.7.2 to 2.7.4
- Update `object` from 0.35.0 to 0.36.0
- Update `process-stream` from 0.3.3 to 0.4.1
- Update `redox_syscall` from 0.5.1 to 0.5.2
- Update `regex` from 1.10.4 to 1.10.5
- Update `regex-automata` from 0.4.6 to 0.4.7
- Update `regex-syntax` from 0.8.3 to 0.8.4
- Add new package `stable_deref_trait` version 1.2.0
- Add new package `synstructure` version 0.13.1
- Replace `tinyvec` with `tinystr` version 0.7.6
- Update `url` from 2.5.0 to 2.5.1
- Add new packages `utf16_iter` version 1.0.5 and `utf8_iter` version 1.0.4
- Add new package `write16` version 1.0.0
- Add new package `writeable` version 0.5.5
- Add new packages `yoke` version 0.7.4 and `yoke-derive` version 0.7.4
- Add new packages `zerofrom` version 0.1.4 and `zerofrom-derive` version 0.1.4
- Add new packages `zerovec` version 0.10.2 and `zerovec-derive` version 0.10.2

* fix: update cargoSha256 hash for vorpal package

Updated the cargoSha256 hash for the vorpal package in flake.nix to ensure the correct dependencies are fetched and built.
  • Loading branch information
erikreinert authored Jun 15, 2024
1 parent ad272e5 commit 645801d
Show file tree
Hide file tree
Showing 25 changed files with 1,355 additions and 649 deletions.
332 changes: 279 additions & 53 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async-compression = { version = "0", features = ["all"] }
clap = { version = "4", features = ["derive"] }
dirs = "5"
flate2 = "1"
futures = "0"
futures-util = "0"
git2 = "0"
hex = "0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ You can also run specific commands by appending them to the `vorpal` binary. For

```bash
$ ./vorpal generate keys # create signing keys
$ ./vorpal service build start # start builder
$ ./vorpal service proxy start # start proxy
$ ./vorpal service build # start builder
$ ./vorpal service proxy # start proxy
```

Or, if you'd like to start all services with `nix` run:
Expand Down
9 changes: 4 additions & 5 deletions api/v0/build/build.proto → api/v0/command/command.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";

package vorpal.build.v0;
package vorpal.command.v0;

service BuildService {
rpc Package (PackageRequest) returns (PackageResponse);
service CommandService {
rpc Package (PackageRequest) returns (stream PackageResponse);
}

enum PackageSourceKind {
Expand All @@ -21,8 +21,7 @@ message PackageSource {
}

message PackageResponse {
string source_id = 1;
string source_hash = 2;
string package_log = 1;
}

message PackageRequest {
Expand Down
10 changes: 6 additions & 4 deletions api/v0/package/package.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ syntax = "proto3";
package vorpal.package.v0;

service PackageService {
rpc Prepare (stream PrepareRequest) returns (PrepareResponse);
rpc Build (BuildRequest) returns (BuildResponse);
rpc Prepare (stream PrepareRequest) returns (stream PrepareResponse);
rpc Build (BuildRequest) returns (stream BuildResponse);
}

enum Status {
Expand All @@ -21,7 +21,8 @@ message PrepareRequest {
}

message PrepareResponse {
int32 source_id = 1;
string source_log = 1;
int32 source_id = 2;
}

message BuildRequest {
Expand All @@ -33,6 +34,7 @@ message BuildRequest {
}

message BuildResponse {
bool is_compressed = 1;
bool is_archive = 1;
bytes package_data = 2;
string package_log = 3;
}
6 changes: 4 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.compile(&["build/build.proto", "package/package.proto"], &["api/v0"])?;
tonic_build::configure().compile(
&["command/command.proto", "package/package.proto"],
&["api/v0"],
)?;
Ok(())
}
Loading

0 comments on commit 645801d

Please sign in to comment.