実行コマンド
printf '\x00\x00\x00\x00\x00' |
curl \
-v -s --http2 \
--data-binary @- \
--output - \
-H "Content-Type: application/grpc" \
-H "TE: trailers" \
"${GRPC_ENDPOINT:?}/grpc.health.v1.Health/Check" |
hexdump -C
空のメッセージを /grpc.health.v1.Health/Check 宛に送ってあげれば良い。
実行例
- リクエスト:
00 00 00 00 00- 最初の 1 バイト
00は圧縮フラグ(0 = 非圧縮) - 次の 4 バイト
00 00 00 00はメッセージ長(0バイト)
- 最初の 1 バイト
$ printf '\x00\x00\x00\x00\x00' | curl -v -s --http2 -H "Content-Type: application/grpc" -H "TE: trailers" --data-binary @- --output - "${GRPC_ENDPOINT:?}/grpc.health.v1.Health/Check" | hexdump -C
... 略 ...
00000000 00 00 00 00 02 08 01 |.......|
00000007
- レスポンス
00 00 00 00 02 08 01- 最初の5バイト
00 00 00 00 02- 最初の 1 バイト
00は圧縮フラグ(0 = 非圧縮) - 次の 4 バイト
00 00 00 02はメッセージ長(2バイト)
- 最初の 1 バイト
- 残りの2バイト
08 01- これは Protocol Buffers でエンコードされたメッセージ
-
08はHealthCheckResponseの field number1のメッセージであることを示している-
(field_number << 3) | wire_type==(status << 3) | VARINT==(1 << 3) | 0==08 - ref: Message Structure | Encoding | Protocol Buffers Documentation
-
-
01はServingStatusがSERVINGであることを示している
- 最初の5バイト