The GRPC Plugin
is a infrastructure Plugin which allows app plugins
to handle GRPC requests (see the diagram below) in this sequence:
- GRPC Plugin starts the GRPC server + net listener in its own goroutine
- Plugins register their handlers with
GRPC Plugin
. To service GRPC requests, a plugin must first implement a handler function and register it at a given URL path using theRegisterService
method.GRPC Plugin
uses an GRPC request multiplexer from thegrpc/Server
. - GRPC server routes GRPC requests to their respective registered handlers
using the
grpc/Server
.
Configuration
- the server's port can be defined using commandline flag
grpc-port
or via the environment variable GRPC_PORT.
Example
The [grpc-server greeter example]*(../../examples/grpc-plugin/grpc-server)
demonstrates the usage of the GRPC Plugin
plugin API GetServer():
// Register our GRPC request handler/service using generated RegisterGreeterServer:
RegisterGreeterServer(plugin.GRPC.Server(), &GreeterService{})
Once the handler is registered with GRPC Plugin
and the agent is running,
you can use grpc client to call the service (see example)