Skip to content

Commit

Permalink
refactor!: dapr no longer requires protoc or tonic_build (#206)
Browse files Browse the repository at this point in the history
* refactor!: dapr no longer requires protoc or tonic_build
The dapr crate no longer requires tonic_build or protoc to build.
The examples have been moved into a separate crate.
proto-gen is now compiling the dapr and example protos.

Signed-off-by: mikeee <[email protected]>

* chore: fmt run

Signed-off-by: mikeee <[email protected]>

* chore: update example names

Signed-off-by: mikeee <[email protected]>

* fix: add a build step

Signed-off-by: mikeee <[email protected]>

* test: remove ci build step and add it to the examples

Signed-off-by: mikeee <[email protected]>

* fix: update validation workflows

Signed-off-by: mikeee <[email protected]>

* tests: tweaks to timings

Signed-off-by: mikeee <[email protected]>

---------

Signed-off-by: mikeee <[email protected]>
  • Loading branch information
mikeee authored Aug 19, 2024
1 parent 7aef43a commit 6301ee4
Show file tree
Hide file tree
Showing 86 changed files with 9,298 additions and 228 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
with:
version: ${{ env.PROTOC_VERSION }}
- uses: actions/checkout@v2
- name: cargo publish macros
run: cargo publish --manifest-path macros/Cargo.toml --token ${{ env.CARGO_TOKEN }}
- name: cargo publish
- name: cargo publish dapr-macros
run: cargo publish --manifest-path dapr-macros/Cargo.toml --token ${{ env.CARGO_TOKEN }}
- name: cargo publish dapr
run: cargo publish --token ${{ env.CARGO_TOKEN }}
3 changes: 0 additions & 3 deletions .github/workflows/validate-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ jobs:
python -m pip install --upgrade pip
pip install mechanical-markdown
- name: Cargo Build Examples
run: cargo build --examples

- name: Dapr version
run: |
dapr version
Expand Down
116 changes: 8 additions & 108 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,108 +1,8 @@
[package]
name = "dapr"
version = "0.15.0"
authors = ["dapr.io"]
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/dapr/rust-sdk"
description = "Rust SDK for dapr"
readme = "README.md"
keywords = ["microservices", "dapr"]

[dependencies]
dapr-macros = { version = "0.15.0", path = "macros" }
futures = "0.3"
tonic = "0.11.0"
prost = "0.12.3"
bytes = "1"
prost-types = "0.12.3"
async-trait = "0.1"
env_logger = "0.11.2"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
axum = "0.7.4"
tokio = { version = "1.29", features = ["sync"] }
tokio-util = { version = "0.7.10", features = ["io"] }
chrono = "0.4.38"
base64 = "0.22.1"

[build-dependencies]
tonic-build = "0.11.0"

[dev-dependencies]
axum-test = "15.0.1"
once_cell = "1.18.0"
tokio = { version = "1", features = ["full"] }
uuid = { version = "1.4.0", features = ["v4"] }
dapr = { path = "./" }
tokio-test = "0.4.2"
tokio-stream = { version = "0.1" }

[[example]]
name = "actor-client"
path = "examples/actors/client.rs"

[[example]]
name = "actor-server"
path = "examples/actors/server.rs"

[[example]]
name = "client"
path = "examples/client/client.rs"

[[example]]
name = "configuration"
path = "examples/configuration/main.rs"

[[example]]
name = "crypto"
path = "examples/crypto/main.rs"

[[example]]
name = "invoke-grpc-client"
path = "examples/invoke/grpc/client.rs"

[[example]]
name = "invoke-grpc-server"
path = "examples/invoke/grpc/server.rs"

[[example]]
name = "invoke-grpc-proxying-client"
path = "examples/invoke/grpc-proxying/client.rs"

[[example]]
name = "invoke-grpc-proxying-server"
path = "examples/invoke/grpc-proxying/server.rs"

[[example]]
name = "jobs"
path = "examples/jobs/jobs.rs"

[[example]]
name = "publisher"
path = "examples/pubsub/publisher.rs"

[[example]]
name = "subscriber"
path = "examples/pubsub/subscriber.rs"

[[example]]
name = "output-bindings"
path = "examples/bindings/output.rs"

[[example]]
name = "input-bindings"
path = "examples/bindings/input.rs"

[[example]]
name = "query_state_q1"
path = "examples/query_state/query1.rs"

[[example]]
name = "query_state_q2"
path = "examples/query_state/query2.rs"

[[example]]
name = "secrets-bulk"
path = "examples/secrets-bulk/app.rs"
[workspace]
members = [
"dapr",
"dapr-macros",
"examples",
"proto-gen",
]
resolver = "2"
15 changes: 0 additions & 15 deletions build.rs

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions macros/src/lib.rs → dapr-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::iter;

use proc_macro2::TokenTree;
use quote::{format_ident, quote};
use syn::{Ident, LitStr, parse_macro_input};
use syn::parse::{Parse, ParseStream};
use syn::{parse_macro_input, Ident, LitStr};

macro_rules! derive_parse {(
@derive_only
Expand Down Expand Up @@ -236,4 +236,4 @@ pub fn topic(args: TokenStream, input: TokenStream) -> TokenStream {
};

tokens.into()
}
}
37 changes: 37 additions & 0 deletions dapr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "dapr"
version = "0.15.0"
authors = ["dapr.io"]
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/dapr/rust-sdk"
description = "Rust SDK for dapr"
readme = "../README.md"
keywords = ["microservices", "dapr"]

[dependencies]
dapr-macros = { version = "0.15.0", path = "../dapr-macros" }
futures = "0.3"
tonic = "0.11.0"
prost = "0.12.3"
bytes = "1"
prost-types = "0.12.3"
async-trait = "0.1"
env_logger = "0.11.2"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
axum = "0.7.4"
tokio = { version = "1.29", features = ["sync"] }
tokio-util = { version = "0.7.10", features = ["io"] }
chrono = "0.4.38"
base64 = "0.22.1"

[dev-dependencies]
axum-test = "15.0.1"
once_cell = "1.18.0"
tokio = { version = "1", features = ["full"] }
uuid = { version = "1.4.0", features = ["v4"] }
dapr = { path = "./" }
tokio-test = "0.4.2"
tokio-stream = { version = "0.1" }
7 changes: 3 additions & 4 deletions src/appcallback.rs → dapr/src/appcallback.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::dapr;
use crate::dapr::proto::runtime::v1::app_callback_server::AppCallback;
use crate::dapr::proto::{common, runtime};
use std::collections::HashMap;
use tonic::{Code, Request, Response, Status};

use crate::dapr::dapr::proto::runtime::v1::app_callback_server::AppCallback;
use crate::dapr::dapr::proto::{common, runtime};
use crate::dapr::*;

/// InvokeRequest is the message to invoke a method with the data.
pub type InvokeRequest = dapr::proto::common::v1::InvokeRequest;

Expand Down
28 changes: 13 additions & 15 deletions src/client.rs → dapr/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::fmt::Debug;

use async_trait::async_trait;
use futures::StreamExt;
Expand All @@ -11,7 +10,7 @@ use tonic::codegen::tokio_stream;
use tonic::{transport::Channel as TonicChannel, Request};
use tonic::{Status, Streaming};

use crate::dapr::dapr::proto::{common::v1 as common_v1, runtime::v1 as dapr_v1};
use crate::dapr::proto::{common::v1 as common_v1, runtime::v1 as dapr_v1};
use crate::error::Error;

#[derive(Clone)]
Expand Down Expand Up @@ -876,39 +875,39 @@ pub type UnsubscribeConfigurationResponse = dapr_v1::UnsubscribeConfigurationRes
pub type TonicClient = dapr_v1::dapr_client::DaprClient<TonicChannel>;

/// Encryption gRPC request
pub type EncryptRequest = crate::dapr::dapr::proto::runtime::v1::EncryptRequest;
pub type EncryptRequest = crate::dapr::proto::runtime::v1::EncryptRequest;

/// Decrypt gRPC request
pub type DecryptRequest = crate::dapr::dapr::proto::runtime::v1::DecryptRequest;
pub type DecryptRequest = crate::dapr::proto::runtime::v1::DecryptRequest;

/// Encryption request options
pub type EncryptRequestOptions = crate::dapr::dapr::proto::runtime::v1::EncryptRequestOptions;
pub type EncryptRequestOptions = crate::dapr::proto::runtime::v1::EncryptRequestOptions;

/// Decryption request options
pub type DecryptRequestOptions = crate::dapr::dapr::proto::runtime::v1::DecryptRequestOptions;
pub type DecryptRequestOptions = crate::dapr::proto::runtime::v1::DecryptRequestOptions;

/// The basic job structure
pub type Job = crate::dapr::dapr::proto::runtime::v1::Job;
pub type Job = crate::dapr::proto::runtime::v1::Job;

/// A request to schedule a job
pub type ScheduleJobRequest = crate::dapr::dapr::proto::runtime::v1::ScheduleJobRequest;
pub type ScheduleJobRequest = crate::dapr::proto::runtime::v1::ScheduleJobRequest;

/// A response from a schedule job request
pub type ScheduleJobResponse = crate::dapr::dapr::proto::runtime::v1::ScheduleJobResponse;
pub type ScheduleJobResponse = crate::dapr::proto::runtime::v1::ScheduleJobResponse;

/// A request to get a job
pub type GetJobRequest = crate::dapr::dapr::proto::runtime::v1::GetJobRequest;
pub type GetJobRequest = crate::dapr::proto::runtime::v1::GetJobRequest;

/// A response from a get job request
pub type GetJobResponse = crate::dapr::dapr::proto::runtime::v1::GetJobResponse;
pub type GetJobResponse = crate::dapr::proto::runtime::v1::GetJobResponse;

/// A request to delete a job
pub type DeleteJobRequest = crate::dapr::dapr::proto::runtime::v1::DeleteJobRequest;
pub type DeleteJobRequest = crate::dapr::proto::runtime::v1::DeleteJobRequest;

/// A response from a delete job request
pub type DeleteJobResponse = crate::dapr::dapr::proto::runtime::v1::DeleteJobResponse;
pub type DeleteJobResponse = crate::dapr::proto::runtime::v1::DeleteJobResponse;

type StreamPayload = crate::dapr::dapr::proto::common::v1::StreamPayload;
type StreamPayload = crate::dapr::proto::common::v1::StreamPayload;
impl<K> From<(K, Vec<u8>)> for common_v1::StateItem
where
K: Into<String>,
Expand All @@ -930,7 +929,6 @@ impl<T: AsyncRead> ReaderStream<T> {
}
}

#[derive(Debug)]
pub struct JobBuilder {
schedule: Option<String>,
data: Option<Any>,
Expand Down
3 changes: 3 additions & 0 deletions dapr/src/dapr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# dapr

These are compiled by running the proto-gen crate
Loading

0 comments on commit 6301ee4

Please sign in to comment.