http2-client-grpc- Implement gRPC-over-HTTP2 clients.

Safe HaskellNone




A module adding support for gRPC over HTTP2.


Building blocks.

data RPC s (m :: Symbol) #

A proxy type for giving static information about RPCs.



type Authority = ByteString #

The HTTP2-Authority portion of an URL (e.g., "").

newtype Timeout #

Timeout in seconds.


Timeout Int 

open Source #


:: (Service s, HasMethod s m) 
=> Http2Client

A connected HTTP2 client.

-> Authority

The HTTP2-Authority portion of the URL (e.g., "").

-> HeaderList

A set of HTTP2 headers (e.g., for adding authentication headers).

-> Timeout

Timeout in seconds.

-> Encoding

Compression used for encoding.

-> Decoding

Compression allowed for decoding

-> RPCCall s m a

The actual RPC handler.

-> IO (Either TooMuchConcurrency a) 

Main handler to perform gRPC calls to a service.

type RawReply a = Either ErrorCode (HeaderList, Maybe HeaderList, Either String a) Source #

A reply.

This reply object contains a lot of information because a single gRPC call returns a lot of data. A future version of the library will have a proper data structure with properly named-fields on the reply object.

For now, remember: - 1st item: initial HTTP2 response - 2nd item: second (trailers) HTTP2 response - 3rd item: proper gRPC answer


singleRequest Source #


:: (Service s, HasMethod s m) 
=> RPC s m

RPC to call.

-> MethodInput s m

RPC's input.

-> RPCCall s m (RawReply (MethodOutput s m)) 

gRPC call for an unary request.

streamReply Source #


:: (Service s, HasMethod s m, MethodStreamingType s m ~ ServerStreaming) 
=> RPC s m

RPC to call.

-> a

An initial state.

-> MethodInput s m

The input.

-> (a -> HeaderList -> MethodOutput s m -> IO a)

A state-passing handler that is called with the message read.

-> RPCCall s m (a, HeaderList, HeaderList) 

gRPC call for Server Streaming.

streamRequest Source #


:: (Service s, HasMethod s m, MethodStreamingType s m ~ ClientStreaming) 
=> RPC s m

RPC to call.

-> a

An initial state.

-> (a -> IO (a, Either StreamDone (CompressMode, MethodInput s m)))

A state-passing action to retrieve the next message to send to the server.

-> RPCCall s m (a, RawReply (MethodOutput s m)) 

gRPC call for Client Streaming.

data StreamDone Source #




data InvalidState Source #

Exception raised when a ServerStreaming RPC results in an invalid state machine.


InvalidState String 

Compression of individual messages.

data Compression #

Opaque type for handling compression.

So far, only "pure" compression algorithms are supported. TODO: suport IO-based compression implementations once we move from Builder.

gzip :: Compression #

Use gzip as compression.

uncompressed :: Compression #

Do not compress.