Skip to content

Commit

Permalink
first working pass at GrpcUrlProviders
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoverson committed Jun 22, 2021
1 parent da9d912 commit 5fedbfc
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 734 deletions.
34 changes: 8 additions & 26 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ thiserror = "1.0.24"
oci-distribution = "0.6"
unsafe-io = "= 0.6.2"
vino-runtime = { path="./crates/vino-runtime" }
vino-transport = { path="./crates/vino-transport" }
vino-host = { path="./crates/vino-host" }
logger = { path="./crates/logger" }
vino-manifest = { path="./crates/vino-manifest" }
Expand Down
1 change: 1 addition & 0 deletions crates/vino-guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl Display for Signal {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum OutputPayload {
Test(String),
MessagePack(Vec<u8>),
Exception(String),
Error(String),
Expand Down
3 changes: 2 additions & 1 deletion crates/vino-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ edition = "2018"
[dependencies]
vino-runtime = { path="../vino-runtime" }
log = "0.4.14"
actix = "0.11"
actix = "0.12"
actix-rt = "2.1.0"
thiserror = "1.0.25"
nkeys = "0.1.0"
serde = { version="1.0.126", features=["derive"] }
serde_yaml = "0.8.17"
hocon = "0.5.2"
vino-manifest = { path="../vino-manifest" }
vino-transport = { path="../vino-transport" }

[dev-dependencies]
test-env-log = "0.2.7"
Expand Down
2 changes: 2 additions & 0 deletions crates/vino-host/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub enum VinoHostError {
#[error(transparent)]
VinoError(#[from] vino_runtime::Error),
#[error(transparent)]
TransportError(#[from] vino_transport::Error),
#[error(transparent)]
ManifestError(#[from] vino_manifest::Error),
#[error("Invalid host state for operation: {0}")]
InvalidHostState(String),
Expand Down
6 changes: 2 additions & 4 deletions crates/vino-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ mod test {
use std::path::PathBuf;

use maplit::hashmap;
use vino_runtime::{
deserialize,
MessagePayload,
};
use vino_runtime::MessagePayload;
use vino_transport::deserialize;

use crate::host_definition::HostDefinition;
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/vino-provider-test/schemas/test.widl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace "vino::test::provider"
namespace "test-component"

type Inputs {
input: string
Expand Down
14 changes: 7 additions & 7 deletions crates/vino-provider-test/src/components/generated/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use vino_rpc::port::{
use vino_transport::deserialize;

#[derive(Debug, PartialEq, Deserialize, Serialize, Default, Clone)]
pub struct Inputs {
pub input: String,
pub(crate) struct Inputs {
pub(crate) input: String,
}

pub(crate) fn inputs_list() -> Vec<String> {
Expand All @@ -26,27 +26,27 @@ pub(crate) fn inputs_list() -> Vec<String> {
#[derive(Debug, PartialEq, Deserialize, Serialize, Default, Clone)]
pub(crate) struct InputEncoded {
#[serde(rename = "input")]
pub input: Vec<u8>,
pub(crate) input: Vec<u8>,
}

pub(crate) fn deserialize_inputs(
args: InputEncoded,
) -> std::result::Result<Inputs, Box<dyn std::error::Error + Send + Sync>> {
) -> Result<Inputs, Box<dyn std::error::Error + Send + Sync>> {
Ok(Inputs {
input: deserialize(&args.input)?,
})
}

#[derive(Default)]
pub struct Outputs {
pub(crate) struct Outputs {
pub(crate) output: OutputSender,
}

pub(crate) fn outputs_list() -> Vec<String> {
vec!["output".to_string()]
}

pub struct OutputSender {
pub(crate) struct OutputSender {
port: Arc<Mutex<Port>>,
}
impl Default for OutputSender {
Expand All @@ -64,7 +64,7 @@ impl Sender for OutputSender {
}
}

pub fn get_outputs() -> (Outputs, Receiver) {
pub(crate) fn get_outputs() -> (Outputs, Receiver) {
let outputs = Outputs::default();
let ports = vec![outputs.output.port.clone()];
let receiver = Receiver::new(ports);
Expand Down
2 changes: 1 addition & 1 deletion crates/vino-provider-test/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn get_component(
name: &str,
) -> Option<Box<dyn VinoProviderComponent<Context = crate::State> + Sync + Send>> {
match name {
"vino::test::provider" => Some(Box::new(test::Component::default())),
"test-component" => Some(Box::new(test::Component::default())),
_ => None,
}
}
2 changes: 1 addition & 1 deletion crates/vino-provider-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl RpcHandler for Provider {
let future = instance.job_wrapper(context, &payload);
Ok(future.await?)
}
None => Err(anyhow!("Component not found").into()),
None => Err(anyhow!("Component '{}' not found", component).into()),
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions crates/vino-rpc/src/component_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,29 @@ use crate::{
MessagePayload,
Output,
PayloadKind,
RpcHandler,
};
pub struct ComponentService {
pub provider: Arc<Mutex<dyn crate::RpcHandler>>,
}

impl ComponentService {
pub fn new<T>(provider: T) -> Self
where
T: RpcHandler + 'static,
{
Self {
provider: Arc::new(Mutex::new(provider)),
}
}
pub fn new_shared<T>(provider: Arc<Mutex<T>>) -> Self
where
T: RpcHandler + 'static,
{
Self { provider }
}
}

pub fn make_output(port: &str, inv_id: &str, payload: OutputPayload) -> Result<Output, Status> {
match serialize(payload) {
Ok(bytes) => Ok(Output {
Expand Down
5 changes: 5 additions & 0 deletions crates/vino-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ oci-distribution = "0.6.0"
nkeys = "0.1.0"
derivative = "2.2.0"
derive-new = "0.5.9"
tokio = { version="1.4.0", features=["macros", "net", "rt-multi-thread"] }
tonic = { version="0.4.3", features=["tls"] }
tokio-stream = "0.1.6"

[dev-dependencies]
env_logger = "0.8.3"
test-env-log = "0.2.7"
maplit = "1.0.2"
vino-provider-test = { path="../vino-provider-test" }
tonic = "0.4.3"
2 changes: 0 additions & 2 deletions crates/vino-runtime/src/components/grpc_host.rs

This file was deleted.

Loading

0 comments on commit 5fedbfc

Please sign in to comment.