Skip to content

Commit d324491

Browse files
committed
use grpc standard health check in python client
1 parent 7b724bf commit d324491

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

client/fossildb-client

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ import sys
77
import fossildbapi_pb2 as proto
88
import fossildbapi_pb2_grpc as proto_rpc
99

10+
from grpc_health.v1 import health_pb2
11+
from grpc_health.v1 import health_pb2_grpc
1012

1113
def main():
1214

1315
commands = {
14-
'backup': lambda stub:
16+
'backup': lambda stub, healthStub:
1517
stub.Backup(proto.BackupRequest()),
16-
'restore': lambda stub:
18+
'restore': lambda stub, healthStub:
1719
stub.RestoreFromBackup(proto.RestoreFromBackupRequest()),
18-
'health': lambda stub:
19-
stub.Health(proto.HealthRequest())
20+
'health': lambda stub, healthStub:
21+
healthStub.Check(health_pb2.HealthCheckRequest(service=''))
2022
}
2123

2224
parser = argparse.ArgumentParser()
@@ -43,8 +45,9 @@ def main():
4345

4446
channel = grpc.insecure_channel(full_address)
4547
stub = proto_rpc.FossilDBStub(channel)
48+
healthStub = health_pb2_grpc.HealthStub(channel)
4649

47-
reply = commands[args.command](stub)
50+
reply = commands[args.command](stub, healthStub)
4851

4952
print(reply)
5053
if not reply.success:

client/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
argparse
22
grpcio-tools
3+
grpcio-health-checking

0 commit comments

Comments
 (0)