grpc unikernel#
A gRPC service as a Solo5 unikernel, on the nox-mirage.eio backend. It is the
minimal use of the Mirage_eio.Grpc device: the device owns
the listener and the HTTP/2 connection handling (it is Grpc_eio.Server.run
bound to a declared net device), so the unikernel supplies only the method
implementations.

The service, echo.Echo, is defined once in rpc/ and shared
between the unikernel and the host client that drives it -- what a .proto
would otherwise generate. Its methods carry raw bytes
(application/grpc+raw) rather than protobuf, so the demo needs no schema
compiler.
For a gRPC appliance that a stock client speaks to, see
etcd: the same device, serving the real etcd v3 API to
etcdctl.
Run on the host (native dev backend)#
A plain dune build links the native backend, which runs the same portable Eio
over an in-process ocaml-slirp gateway. Publish the guest's port with -p and
call through it:
dune exec -- unikernel-grpc -p 50051:50051
dune exec -- unikernel-grpc-client reverse "hello unikernel"
dune exec -- unikernel-grpc-client upper "hello unikernel"
The client ships with the example because there is no stock CLI for a raw-codec
service: grpcurl needs protobuf reflection or a .proto.
Build and run under Solo5#
mrg up
mrg build -t solo5 unikernels/bin/apps/grpc
mrg run -p 50051:50051 unikernels/bin/apps/grpc
The unikernel binds 10.0.0.2:50051 in the guest; the published port reaches it
from the host.