gRPC using JSON as the message encoding
"JSON over gRPC" is a bit of an ambiguous phrase. It can be a very general
term, simply meaning using an otherwise-unspecified JSON encoding, or it can
refer to "Protobuf over JSON" (see
https://protobuf.dev/programming-guides/proto3/#json). In this module we
deal with the former, and don't deal with anything Protobuf-specific at all,
nor do we rely on any of the infrastructure generated by the Protobuf
compiler (in other words, there is no need to use protoc). See
https://grpc.io/blog/grpc-with-json/ for a Java example of using gRPC with
JSON without Protobuf.
In the absence of the infrastructure provided by protoc, you will need to
manually provide Input and Output instances for each RPC you use.
For example:
type Create = JsonRpc KeyValueService "Create"
type Delete = JsonRpc KeyValueService "Delete"
..
type instance Input Create = ..
type instance Output Create = ..
type instance Input Retrieve = ..
type instance Output Retrieve = ..
..On the client, you will need ToJSON instances for inputs and FromJSON instances for outputs; on the server the situation is dual. You may find it convenient to use JsonObject (but this is certainly not required).
TODO: https://github.com/well-typed/grapesy/issues/166 We don't currently offer explicit support for "Protobuf JSON".
Instances4IsRPC, SupportsClientRpc, SupportsServerRpc, SupportsStreamingType
(KnownSymbol serv, KnownSymbol meth, NFData (Input (JsonRpc serv meth)), NFData (Output (JsonRpc serv meth)), Show (Input (JsonRpc serv meth)), Show (Output (JsonRpc serv meth)), Show (RequestMetadata (JsonRpc serv meth)), Show (ResponseInitialMetadata (JsonRpc serv meth)), Show (ResponseTrailingMetadata (JsonRpc serv meth))) => IsRPC (JsonRpc serv meth)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.JSON(IsRPC (JsonRpc serv meth), ToJSON (Input (JsonRpc serv meth)), FromJSON (Output (JsonRpc serv meth)), BuildMetadata (RequestMetadata (JsonRpc serv meth)), ParseMetadata (ResponseInitialMetadata (JsonRpc serv meth)), ParseMetadata (ResponseTrailingMetadata (JsonRpc serv meth))) => SupportsClientRpc (JsonRpc serv meth)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.JSON(IsRPC (JsonRpc serv meth), FromJSON (Input (JsonRpc serv meth)), ToJSON (Output (JsonRpc serv meth)), ParseMetadata (RequestMetadata (JsonRpc serv meth)), BuildMetadata (ResponseInitialMetadata (JsonRpc serv meth)), StaticMetadata (ResponseTrailingMetadata (JsonRpc serv meth))) => SupportsServerRpc (JsonRpc serv meth)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.JSONValidStreamingType styp => SupportsStreamingType (JsonRpc serv meth) stypDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.JSONFor JSON protocol we do not check communication protocols