Skip to content

Commit

Permalink
Merge pull request #73 from asynchronics/feature/grpc_rework
Browse files Browse the repository at this point in the history
Feature/grpc rework
  • Loading branch information
jauhien authored Jan 12, 2025
2 parents 42192dd + 7a95a4d commit 2e0653e
Show file tree
Hide file tree
Showing 19 changed files with 635 additions and 459 deletions.
44 changes: 36 additions & 8 deletions nexosim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ description = """
A high performance asychronous compute framework for system simulation.
"""
categories = ["simulation", "aerospace", "science"]
keywords = ["simulation", "discrete-event", "systems", "cyberphysical", "real-time"]
keywords = [
"simulation",
"discrete-event",
"systems",
"cyberphysical",
"real-time",
]

[features]
# gRPC service.
grpc = ["dep:bytes", "dep:ciborium", "dep:prost", "dep:prost-types", "dep:serde", "dep:tonic", "dep:tokio", "dep:tonic"]
grpc = [
"dep:bytes",
"dep:ciborium",
"dep:prost",
"dep:prost-types",
"dep:serde",
"dep:tonic",
"dep:tokio",
"dep:tonic",
"tai-time/serde",
]
tracing = ["dep:tracing", "dep:tracing-subscriber"]

# DEVELOPMENT ONLY: API-unstable public exports meant for external test/benchmarking.
Expand Down Expand Up @@ -54,15 +70,24 @@ ciborium = { version = "0.2.2", optional = true }
prost = { version = "0.13", optional = true }
prost-types = { version = "0.13", optional = true }
serde = { version = "1", optional = true }
tokio = { version = "1.0", features=["net", "rt-multi-thread"], optional = true }
tonic = { version = "0.12", default-features = false, features=["codegen", "prost", "server"], optional = true }
tracing = { version= "0.1.40", default-features = false, features=["std"], optional = true }
tracing-subscriber = { version= "0.3.18", optional = true }
tokio = { version = "1.0", features = [
"net",
"rt-multi-thread",
], optional = true }
tonic = { version = "0.12", default-features = false, features = [
"codegen",
"prost",
"server",
], optional = true }
tracing = { version = "0.1.40", default-features = false, features = [
"std",
], optional = true }
tracing-subscriber = { version = "0.3.18", optional = true }

[dev-dependencies]
futures-util = "0.3"
futures-executor = "0.3"
tracing-subscriber = { version= "0.3.18", features=["env-filter"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[target.'cfg(nexosim_loom)'.dev-dependencies]
loom = "0.7"
Expand All @@ -74,7 +99,10 @@ tonic-build = { version = "0.12" }
[lints.rust]
# `nexosim_loom` flag: run loom-based tests.
# `nexosim_grpc_codegen` flag: regenerate gRPC code from .proto definitions.
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(nexosim_loom)', 'cfg(nexosim_grpc_codegen)'] }
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(nexosim_loom)',
'cfg(nexosim_grpc_codegen)',
] }

[package.metadata.docs.rs]
all-features = true
Expand Down
43 changes: 21 additions & 22 deletions nexosim/src/grpc/api/simulation.proto
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
// The main simulation protocol.

syntax = "proto3";
package simulation;
package simulation.v1;

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

enum ErrorCode {
INTERNAL_ERROR = 0;
SIMULATION_NOT_STARTED = 1;
SIMULATION_TERMINATED = 2;
SIMULATION_DEADLOCK = 3;
SIMULATION_MESSAGE_LOSS = 4;
SIMULATION_NO_RECIPIENT = 5;
SIMULATION_PANIC = 6;
SIMULATION_TIMEOUT = 7;
SIMULATION_OUT_OF_SYNC = 8;
SIMULATION_BAD_QUERY = 9;
SIMULATION_TIME_OUT_OF_RANGE = 10;
MISSING_ARGUMENT = 20;
INVALID_TIME = 30;
INVALID_PERIOD = 31;
INVALID_DEADLINE = 32;
INVALID_MESSAGE = 33;
INVALID_KEY = 34;
SOURCE_NOT_FOUND = 40;
SINK_NOT_FOUND = 41;
MISSING_ARGUMENT = 1;
INVALID_TIME = 2;
INVALID_PERIOD = 3;
INVALID_DEADLINE = 4;
INVALID_MESSAGE = 5;
INVALID_KEY = 6;
INITIALIZER_PANIC = 10;
SIMULATION_NOT_STARTED = 11;
SIMULATION_TERMINATED = 12;
SIMULATION_DEADLOCK = 13;
SIMULATION_MESSAGE_LOSS = 14;
SIMULATION_NO_RECIPIENT = 15;
SIMULATION_PANIC = 16;
SIMULATION_TIMEOUT = 17;
SIMULATION_OUT_OF_SYNC = 18;
SIMULATION_BAD_QUERY = 19;
SIMULATION_TIME_OUT_OF_RANGE = 20;
SOURCE_NOT_FOUND = 30;
SINK_NOT_FOUND = 31;
}

message Error {
Expand All @@ -39,9 +40,7 @@ message EventKey {
uint64 subkey2 = 2;
}

message InitRequest {
bytes cfg = 2;
}
message InitRequest { bytes cfg = 2; }
message InitReply {
oneof result { // Always returns exactly 1 variant.
google.protobuf.Empty empty = 1;
Expand Down
1 change: 1 addition & 0 deletions nexosim/src/grpc/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
#![allow(missing_docs)]

#[rustfmt::skip]
#[path = "codegen/simulation.v1.rs"]
pub(crate) mod simulation;
Loading

0 comments on commit 2e0653e

Please sign in to comment.