From d2e2edc734151c075251662adfadb639a519cc40 Mon Sep 17 00:00:00 2001 From: Spencer Judge Date: Tue, 12 Jan 2021 17:26:58 -0800 Subject: [PATCH] Makes protobufs actually compile --- Cargo.toml | 7 ++- build.rs | 6 +- protos/{ => local}/core_interface.proto | 2 +- src/lib.rs | 22 ++++++++ src/main.rs | 3 - src/protos/mod.rs | 74 +++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 9 deletions(-) rename protos/{ => local}/core_interface.proto (98%) create mode 100644 src/lib.rs delete mode 100644 src/main.rs create mode 100644 src/protos/mod.rs diff --git a/Cargo.toml b/Cargo.toml index bd148b7d1..059a855dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,11 +4,14 @@ version = "0.1.0" authors = ["Spencer Judge ", "Vitaly Arbuzov "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] [dependencies] -tonic = "0.3" +async-trait = "0.1" prost = "0.6" +prost-types = "0.6" +thiserror = "1.0" +tonic = "0.3" [build-dependencies] tonic-build = "0.3" \ No newline at end of file diff --git a/build.rs b/build.rs index d68d98664..fedb297a6 100644 --- a/build.rs +++ b/build.rs @@ -5,8 +5,8 @@ fn main() -> Result<(), Box> { .build_server(false) .build_client(false) .compile( - &["protos/core_interface.proto"], - &["protos/api_upstream", "protos"], + &["protos/local/core_interface.proto"], + &["protos/api_upstream", "protos/local"], )?; Ok(()) -} \ No newline at end of file +} diff --git a/protos/core_interface.proto b/protos/local/core_interface.proto similarity index 98% rename from protos/core_interface.proto rename to protos/local/core_interface.proto index b486404bd..bc40b2bc2 100644 --- a/protos/core_interface.proto +++ b/protos/local/core_interface.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package temporal.api.coresdk.v1; +package coresdk; // Note: Intellij will think these imports don't work because of the slightly odd nature of // the include paths. You can make it work by going to the "Protobuf Support" settings section diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..8422dd78f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,22 @@ +pub mod protos; + +use protos::coresdk::{PollSdkTaskReq, PollSdkTaskResp}; + +type Result = std::result::Result; + +// TODO: Should probably enforce Send + Sync +#[async_trait::async_trait] +pub trait CoreSDKService { + async fn poll_sdk_task(&self, req: PollSdkTaskReq) -> Result; +} + +#[derive(thiserror::Error, Debug)] +pub enum SDKServiceError { + // tbd +} + +#[cfg(test)] +mod test { + #[test] + fn foo() {} +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e7a11a969..000000000 --- a/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/src/protos/mod.rs b/src/protos/mod.rs new file mode 100644 index 000000000..6c22e101d --- /dev/null +++ b/src/protos/mod.rs @@ -0,0 +1,74 @@ +pub mod coresdk { + tonic::include_proto!("coresdk"); +} + +// This is disgusting, but unclear to me how to avoid it. TODO: Discuss w/ prost maintainer +pub mod temporal { + pub mod api { + pub mod command { + pub mod v1 { + tonic::include_proto!("temporal.api.command.v1"); + } + } + pub mod enums { + pub mod v1 { + tonic::include_proto!("temporal.api.enums.v1"); + } + } + pub mod failure { + pub mod v1 { + tonic::include_proto!("temporal.api.failure.v1"); + } + } + pub mod filter { + pub mod v1 { + tonic::include_proto!("temporal.api.filter.v1"); + } + } + pub mod common { + pub mod v1 { + tonic::include_proto!("temporal.api.common.v1"); + } + } + pub mod history { + pub mod v1 { + tonic::include_proto!("temporal.api.history.v1"); + } + } + pub mod namespace { + pub mod v1 { + tonic::include_proto!("temporal.api.namespace.v1"); + } + } + pub mod query { + pub mod v1 { + tonic::include_proto!("temporal.api.query.v1"); + } + } + pub mod replication { + pub mod v1 { + tonic::include_proto!("temporal.api.replication.v1"); + } + } + pub mod taskqueue { + pub mod v1 { + tonic::include_proto!("temporal.api.taskqueue.v1"); + } + } + pub mod version { + pub mod v1 { + tonic::include_proto!("temporal.api.version.v1"); + } + } + pub mod workflow { + pub mod v1 { + tonic::include_proto!("temporal.api.workflow.v1"); + } + } + pub mod workflowservice { + pub mod v1 { + tonic::include_proto!("temporal.api.workflowservice.v1"); + } + } + } +}