Skip to content

Commit a7ad61b

Browse files
1 parent cfb17a1 commit a7ad61b

5 files changed

Lines changed: 97 additions & 4 deletions

File tree

Proto/Build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ORIGIN INFORMATION:
2+
// This code block was extracted by a script.
3+
// Source Markdown File: Backup/MountainFinalSync/Document/14_MODEL.md
4+
// Source Block Index in MD (Overall): 3
5+
// Original Fence Info String: (empty)
6+
// Content SHA256 (of this block):
7+
// 7bbaddc3d4a89cda326f09f7335e4a06b4cc0179bb7e5601667744c7198028e1 Extracted to
8+
// File: Backup/MountainFinalSync/Code/mountain/build.rs Extraction Timestamp:
9+
// 2025-06-18T18:53:42.858Z --- END OF ORIGIN INFORMATION ---
10+
11+
// @file build.rs
12+
// @brief The build script for the Mountain crate.
13+
// @description This script uses `tonic-build` to compile the Protobuf
14+
// definitions in `Vine.proto` into Rust code, which is then included by the
15+
// `Vine::Generated` module.
16+
17+
fn main() -> Result<(), Box<dyn std::error::Error>> {
18+
println!("cargo:rerun-if-changed=Vine.proto");
19+
20+
tonic_build::configure()
21+
.build_server(true)
22+
.build_client(true)
23+
.out_dir("Source/Vine/Generated")
24+
.compile(&["Vine.proto"], &["proto"])?;
25+
26+
Ok(())
27+
}

Proto/Vine.proto

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// @file vine.proto
2+
// @brief Defines the gRPC services and messages for communication between Mountain (host) and Cocoon (sidecar).
3+
4+
syntax = "proto3";
5+
6+
package vine_ipc;
7+
8+
// Service running on the Mountain host, listening for requests from Cocoon.
9+
service MountainService {
10+
// A generic request-response method for Cocoon to call a function on Mountain.
11+
rpc ProcessCocoonRequest(GenericRequest) returns (GenericResponse);
12+
// A generic fire-and-forget method for Cocoon to send a notification to Mountain.
13+
rpc SendCocoonNotification(GenericNotification) returns (Empty);
14+
// A method for Cocoon to request that Mountain cancel a long-running operation.
15+
rpc CancelOperation(CancelOperationRequest) returns (Empty);
16+
}
17+
18+
// Service running on the Cocoon sidecar, listening for requests from Mountain.
19+
service CocoonService {
20+
// A generic request-response method for Mountain to call a function on Cocoon.
21+
rpc ProcessMountainRequest(GenericRequest) returns (GenericResponse);
22+
// A generic fire-and-forget method for Mountain to send a notification to Cocoon.
23+
rpc SendMountainNotification(GenericNotification) returns (Empty);
24+
// A method for Mountain to request that Cocoon cancel a long-running operation.
25+
rpc CancelOperation(CancelOperationRequest) returns (Empty);
26+
}
27+
28+
// Represents an empty message, typically used for RPCs that don't need to return data.
29+
message Empty {}
30+
31+
// A generic request message containing a method name and serialized parameters.
32+
message GenericRequest {
33+
uint64 request_id = 1;
34+
string method = 2;
35+
bytes params = 3; // Parameters are expected to be a JSON-serialized byte array.
36+
}
37+
38+
// A generic response message containing the result or an error.
39+
message GenericResponse {
40+
uint64 request_id = 1;
41+
bytes result = 2; // The successful result, JSON-serialized.
42+
optional RpcError error = 3;
43+
}
44+
45+
// A generic notification message, which is fire-and-forget and does not have an ID.
46+
message GenericNotification {
47+
string method = 1;
48+
bytes params = 2; // Parameters are expected to be a JSON-serialized byte array.
49+
}
50+
51+
// A structured error payload, compliant with JSON-RPC error objects.
52+
message RpcError {
53+
int32 code = 1;
54+
string message = 2;
55+
bytes data = 3; // Optional, additional error data, JSON-serialized.
56+
}
57+
58+
// A message to cancel a specific, ongoing operation.
59+
message CancelOperationRequest {
60+
uint64 request_id_to_cancel = 1;
61+
}
62+
63+
// A generic data payload, currently unused but available for future extensions.
64+
message RpcDataPayload {
65+
bytes data = 1;
66+
}

Source/Vine/Server/Initialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tonic::transport::Server;
1111
use super::MountainVinegRPCService::MountainVinegRPCService;
1212
use crate::{
1313
RunTime::ApplicationRunTime::ApplicationRunTime,
14-
Vine::generated::mountain_service_server::MountainServiceServer,
14+
Vine::Generated::mountain_service_server::MountainServiceServer,
1515
};
1616

1717
/// Initializes and starts the gRPC server on a background task.

Source/Vine/Server/MountainVinegRPCService.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tonic::{Request, Response, Status};
1212

1313
use crate::{
1414
track,
15-
Vine::generated::{mountain_service_server::MountainService, *},
15+
Vine::Generated::{mountain_service_server::MountainService, *},
1616
RunTime::ApplicationRunTime::ApplicationRunTime,
1717
};
1818

Source/Vine/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub mod generated;
2929
pub use self::error::VineError;
3030
// The auto-generated gRPC client for the `CocoonService`.
3131
// @see generated::CocoonServiceClient
32-
pub use self::generated::cocoon_service_client::CocoonServiceClient;
32+
pub use self::Generated::cocoon_service_client::CocoonServiceClient;
3333
// The auto-generated gRPC server trait for the `MountainService`.
3434
// Our `MountainVinegRPCService` will implement this trait.
3535
// @see generated::mountain_service_server::MountainServiceServer;
36-
pub use self::generated::mountain_service_server::MountainServiceServer;
36+
pub use self::Generated::mountain_service_server::MountainServiceServer;

0 commit comments

Comments
 (0)