Skip to content

Instantly share code, notes, and snippets.

@bopin2020
Created October 14, 2021 15:03
Show Gist options
  • Save bopin2020/1474f0dd8679242bfe8fb0041c040ca8 to your computer and use it in GitHub Desktop.
Save bopin2020/1474f0dd8679242bfe8fb0041c040ca8 to your computer and use it in GitHub Desktop.
syntax = "proto3";
// ========================================== Import proto
// import "annotations.proto";
// import "http.proto";
// import "google/protobuf/empty.proto";
// ==========================================
option csharp_namespace = "GrpcTeamServer";
package greet;
// The greeting service definition. package/service/rpc
service Greeter {
// method 1
// Unary
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply);
// https://docs.microsoft.com/en-us/aspnet/core/grpc/services?view=aspnetcore-5.0
// rcp stream
// method 2
// server streaming
rpc StreamingFromServer (HelloRequest) returns (stream HelloReply);
// method 3
// Client streaming
rpc StreamingFromClient (stream HelloRequest) returns (HelloReply);
// method 4
// Bi-directional streaming
rpc StreamingBothWays(stream HelloRequest) returns (stream HelloReply);
/*
Each call type has a different method signature. overridiing generated methods from the abstract base service type
in a concrete implementation ensures the correct arguments and return type are used.
*/
}
// gRPC 认证服务
service Auth{
rpc BearerTokenAuth (AuthRequest) returns (AuthResponse);
}
service DataByte{
rpc WriteFileBytes (FileName) returns (FileBin);
}
message FileName
{
string filename = 1;
}
message FileBin
{
string data = 1;
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
string message = 2;
}
// The response message containing the greetings.
message HelloReply {
string message = 1;
string name = 2;
}
message AuthRequest{
string username = 1;
string password = 2;
}
message AuthResponse{
string username = 1;
string Token = 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment