The OpenHES application provides a public connectRPC interface that is fully compatible with gRPC for efficient and scalable communication.
To integrate OpenHES into your system or automate data readings, you can build your own gRPC client to communicate with OpenHES.
- The following example describes client generation using the
Goprogramming language on macOS. Tool installation is done via Homebrew.- For different languages or operating systems, see the Buf documentation.
Tools Used
- grpcurl - A command line tool for interaction with gRPC servers.
- buf - A tool for managing and generating gRPC code and protocol buffers.
- protoc - A protocol buffer compiler.
- protoc-gen-go / protoc-gen-go-grpc - Code generator plugins for the
Golanguage.
Generate Clients
To generate a client, follwo these steps:
Install the necessary prerequisites.
brew install grpcurl brew install bufbuild/buf/buf go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest export PATH="$PATH:$(go env GOPATH)/bin" brew install protobufDownload the
protofiles.
Replace<host:port>with the address of the openHES server.grpcurl -proto-out-dir=protos <host:port> listGenerate client files from the
protosdirectory.cd protos echo "version: v2 plugins: - local: protoc-gen-go-grpc out: ../gen/go opt: paths=source_relative - protoc_builtin: go out: ../gen/go opt: - paths=source_relative - default_api_level=API_OPAQUE - protoc_builtin: python out: ../gen/python/platform_api - remote: buf.build/grpc/python out: ../gen/python/platform_api" >buf.gen.yaml buf generate
- All client files will be generated and placed in the path
../gen/.
Example YAML File
You can generate clients for multiple programming languages using a single yaml configuration file.
The following example describes client generation using the Go and Python programming languages.
version: v2
plugins:
- local: protoc-gen-go-grpc
out: ../gen/go
opt: paths=source_relative
- protoc_builtin: go
out: ../gen/go
opt:
- paths=source_relative
- default_api_level=API_OPAQUE
- protoc_builtin: python
out: ../gen/python/platform_api
- remote: buf.build/grpc/python
out: ../gen/python/platform_api
For each client defined in the yaml file, ensure that the specified plugin or plugins can generate both data types and API methods.
For a complete description of the yaml file, see the Buf documentation.