gRPC setup

gRPC is an open source RPC (remote procedure call) software used to create services. It uses HTTP/2 for transport and protocol buffers to define the structure of the application. Dialog as a Service supports the gRPC proto3 version.

The basic steps in using the Mix.api gRPC protocol are:

  1. Install gRPC for the programming language of your choice, including C++, Java, Python, Go, Ruby, C#, Node.js, and others. See gRPC Documentation  for a complete list and instructions on using gRPC with each language.

  2. Download the gRPC .proto file. This file contains a generic version of the Mix.api functions or classes.

    pip install --upgrade pip
    pip install grpcio
    pip install grpcio-tools
    
  3. Generate client stub files in your programming language from the proto files, following the Python example as guidance. Depending on your programming language, the stubs may consist of one file or multiple files per proto file.

    echo "Pulling support files"
    mkdir -p google/api
    curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > google/api/annotations.proto
    curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > google/api/http.proto
    echo "generate the stubs for support files"
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ google/api/http.proto
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ google/api/annotations.proto
    echo "generate the stubs for the Mix.api gRPC file"
    python -m grpc_tools.protoc --proto_path=./ --python_out=. --grpc_python_out=. appconfig.proto
    

    These stub files contain the methods and fields from the proto files as implemented in your programming language. You will consult the stubs in conjunction with the proto files. See gRPC API.

  4. Write your client app, referencing the functions or classes in the client stub files.