46 lines
1.7 KiB
Protocol Buffer
46 lines
1.7 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package examples;
|
|
|
|
option go_package = "examples";
|
|
|
|
// The greeting service definition.
|
|
service BidirectionalGreeter {
|
|
// A bidirectional streaming RPC.
|
|
//
|
|
// Accepts a stream of GreetingRequests and returns a stream of GreetingResponses.
|
|
BidirectionalGreeting (stream GreetingRequest) returns (stream GreetingResponse);
|
|
}
|
|
|
|
// The request message containing the user's name.
|
|
message GreetingRequest {
|
|
string name = 1;
|
|
// Add additional request fields here. Consider adding metadata or context.
|
|
string request_id = 2; // Example: a unique request identifier
|
|
}
|
|
|
|
// The response message containing the greetings.
|
|
message GreetingResponse {
|
|
string message = 1;
|
|
// Add additional response fields here. Consider adding status information.
|
|
string server_timestamp = 2; // Example: timestamp of the server when the response was generated
|
|
}
|
|
|
|
// Example usage comments:
|
|
//
|
|
// - The BidirectionalGreeting RPC allows the client and server to exchange multiple messages
|
|
// in a single connection. This is useful for real-time communication or data streaming.
|
|
//
|
|
// - The GreetingRequest can include metadata, such as a request ID, to track individual requests
|
|
// within the stream.
|
|
//
|
|
// - The GreetingResponse can include information about the server's processing, such as a timestamp.
|
|
//
|
|
// - Consider adding error handling and retry mechanisms to your gRPC client to handle potential
|
|
// network issues.
|
|
//
|
|
// - Implement appropriate logging and monitoring to track the performance of your gRPC service.
|
|
//
|
|
// - For production environments, enable TLS for secure communication between the client and server.
|
|
//
|
|
// - Implement interceptors for logging, authentication, and other cross-cutting concerns. |