コード例 #1
0
ファイル: compo1_service.py プロジェクト: singnet/ai-dsl
 def call_incrementer_svc(self, x):
     endpoint = "localhost:{}".format(
         registry["incrementer_service"]["grpc"])
     channel = grpc.insecure_channel(endpoint)
     stub = grpc_incrementer_grpc.IncrementerStub(channel)
     arguments = grpc_incrementer_pb2.Arguments(argument=x)
     return stub.incrementer(arguments).value
コード例 #2
0
# import the generated classes
import service.proto_spec.incrementer_service_pb2_grpc as grpc_tw_grpc
import service.proto_spec.incrementer_service_pb2 as grpc_tw_pb2

from service import registry

if __name__ == "__main__":

    # Call Incrementer Service

    try:
        # Ask endpoint and argument
        dflt_ep = "localhost:{}".format(
            registry["incrementer_service"]["grpc"])
        endpoint = input("Endpoint [default={}]: ".format(dflt_ep)) or dflt_ep
        argument = int(input("Argument [default=41]: ") or 41)

        # Open a gRPC channel
        channel = grpc.insecure_channel(endpoint)
        stub = grpc_tw_grpc.IncrementerStub(channel)
        arguments = grpc_tw_pb2.Arguments(argument=argument)

        # Carry out service
        response = stub.incrementer(arguments)
        print(response.value)

    except Exception as e:
        print(e)
        exit(1)
コード例 #3
0
# import the generated classes
import service.proto_spec.incrementer_service_pb2_grpc as grpc_in_grpc
import service.proto_spec.incrementer_service_pb2 as grpc_in_pb2

from service import registry

if __name__ == "__main__":

    # Call Halfer Service

    try:
        # Ask endpoint and argument
        dflt_ep = "localhost:{}".format(
            registry["incrementer_service"]["grpc"])
        endpoint = input("Endpoint [default={}]: ".format(dflt_ep)) or dflt_ep
        argument = int(input("Argument [default=41]: ") or "41")

        # Open a gRPC channel
        channel = grpc.insecure_channel(endpoint)
        stub = grpc_in_grpc.IncrementerStub(channel)
        arguments = grpc_in_pb2.Arguments(argument=argument)

        # Carry out service
        response = stub.incrementer(arguments)
        print(response.value)

    except Exception as e:
        print(e)
        exit(1)