Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust gRPC server pseudo-node #772

Merged
merged 14 commits into from
Apr 7, 2020
5 changes: 5 additions & 0 deletions Cargo.lock

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

13 changes: 12 additions & 1 deletion oak/proto/application.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ message NodeConfiguration {
WebAssemblyConfiguration wasm_config = 2;
LogConfiguration log_config = 3;
StorageProxyConfiguration storage_config = 4;
GrpcClientConfiguration grpc_client_config = 5;
GrpcServerConfiguration grpc_server_config = 5;
GrpcClientConfiguration grpc_client_config = 6;
}
}

Expand All @@ -73,10 +74,20 @@ message StorageProxyConfiguration {
string address = 1;
}

// GrpcServerConfiguration describes the configuration of a gRPC server
// pseudo-Node (which is provided by the Oak Runtime), that processes gRPC
// requests from external (non-Oak) clients.
message GrpcServerConfiguration {
// The endpoint address for the gRPC server to listen on.
// `address` is represented as an "ip_address:tcp_port" string.
string address = 1;
}

// GrpcClientConfiguration describes the configuration of a gRPC client
// pseudo-Node (which is provided by the Oak Runtime), connected to a specific
// external (non-Oak) gRPC service.
message GrpcClientConfiguration {
// The endpoint address of the external gRPC service.
// `address` is represented as an "ip_address:tcp_port" string.
string address = 1;
}
5 changes: 5 additions & 0 deletions oak/server/rust/oak_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ default = []

[dependencies]
byteorder = { version = "*", default-features = false }
http = "*"
hyper = "*"
itertools = "*"
log = { version = "*" }
oak = "0.1.0"
oak_abi = "=0.1.0"
prost = "*"
protobuf = "*"
rand = { version = "*", default-features = false, features = ["alloc"] }
tokio = { version = "*", features = ["rt-core"] }
wasmi = { version = "*", default-features = false, features = ["core"] }

[dev-dependencies]
Expand Down
15 changes: 12 additions & 3 deletions oak/server/rust/oak_runtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//

use crate::proto::{
node_configuration::ConfigType, ApplicationConfiguration, LogConfiguration, NodeConfiguration,
WebAssemblyConfiguration,
node_configuration::ConfigType, ApplicationConfiguration, GrpcServerConfiguration,
LogConfiguration, NodeConfiguration, WebAssemblyConfiguration,
};
use itertools::Itertools;
use std::collections::HashMap;
Expand All @@ -27,7 +27,7 @@ use log::error;
use oak_abi::OakStatus;

use crate::node;
use crate::node::load_wasm;
use crate::node::{check_port, load_wasm, parse_address};
use crate::runtime;
use crate::runtime::{Handle, Runtime};

Expand Down Expand Up @@ -90,6 +90,15 @@ pub fn from_protobuf(
return Err(OakStatus::ErrInvalidArgs);
}
Some(ConfigType::LogConfig(_)) => node::Configuration::LogNode,
Some(ConfigType::GrpcServerConfig(GrpcServerConfiguration { address })) => {
parse_address(address)
.and_then(|address| check_port(&address).map(|_| address))
.map(|address| node::Configuration::GrpcServerNode { address })
.map_err(|error| {
error!("Incorrect gRPC server address: {:?}", error);
OakStatus::ErrInvalidArgs
})?
}
Some(ConfigType::WasmConfig(WebAssemblyConfiguration { module_bytes, .. })) => {
load_wasm(&module_bytes).map_err(|e| {
error!("Error loading Wasm module: {}", e);
Expand Down
Loading