1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gRPCメソッドの戻り値なしってどーやるんだ

Posted at

こんにちは!:writing_hand_tone3:
業務でgrpcメソッドを書く際に特にレスポンスは不要なケースがあったので実装方法をアウトプットしていきたいと思います。

方法

"google/protobuf/empty.proto"をインポートして戻り値に(google.protobuf.Empty)を指定するだけです。

引数をなしにしたい場合も使えます。

実装例↓

syntax = "proto3";

import "google/protobuf/empty.proto";

package test;


service Testservice {
    rpc TestGetMethod (google.protobuf.Empty) returns (hogehoge);
    rpc TestDeleteMethod (hugahuga) returns (google.protobuf.Empty);
}

Protocol Buffers Well-Known Types

このあたりによく使う型が載っていそう。
https://protobuf.dev/reference/protobuf/google.protobuf/#api

公式ドキュメント

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?