andreasewering / elm-grpc / Grpc.Internal

Internals that are intended to be used from code generators.

Rpc representation


type Rpc req res
    = Rpc ({ service : String, package : String, rpcName : String, encoder : req -> Protobuf.Encode.Encoder, decoder : Protobuf.Decode.Decoder res })

Given the following proto file

"""
syntax = "proto3";

package helloworld;

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}
"""

the corresponding Rpc instance would be

Rpc
    { service = "Greeter"
    , package = "helloworld"
    , rpcName = "SayHello"
    , encoder = helloRequestEncoder
    , decoder = helloReplyDecoder
    }

where helloRequestEncoder and helloReplyDecoder are Encoders/Decoders built with elm-protocol-buffers.