반응형

방법 1 : proto 에 empty.proto import 후 rpc에서 사용

syntax = "proto3";

import "google/protobuf/empty.proto";
option csharp_namespace = "gRPC_Server";

package greet;

service Greeter {
  rpc Test(google.protobuf.Empty) returns (google.protobuf.Empty);
}

방법 2 : Empty 메세지를 정의후 사용

syntax = "proto3";

option csharp_namespace = "gRPC_Server";

package greet;

service Greeter {
  rpc Test(Empty) returns (Empty);
}

message Empty {}

 

    public class GreeterService : Greeter.GreeterBase
    {
        private readonly ILogger<GreeterService> _logger;

        public GreeterService(ILogger<GreeterService> logger)
        {
            _logger = logger;
        }

        public override Task<Empty> Test(Empty request, ServerCallContext context)
        {
            return base.Test(request, context);
        }
    }

 

 

참조 : https://stackoverflow.com/questions/31768665/can-i-define-a-grpc-call-with-a-null-request-or-response

 

Can I define a grpc call with a null request or response?

Does the rpc syntax in proto3 allow null requests or responses? e.g. I want the equivalent of the following: rpc Logout; rpc Status returns (Status); rpc Log (LogData); Or should I just create a n...

stackoverflow.com

 

반응형

+ Recent posts