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

Safe HaskellNone
LanguageHaskell2010

Network.GRPC.Client

Contents

Description

A module adding support for gRPC over HTTP2.

Synopsis

Building blocks.

data RPC s (m :: Symbol) #

A proxy type for giving static information about RPCs.

Constructors

RPC 

type Authority = ByteString #

The HTTP2-Authority portion of an URL (e.g., "dicioccio.fr:7777").

newtype Timeout #

Timeout in seconds.

Constructors

Timeout Int 

open Source #

Arguments

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

A token carrying information specifying the RPC to call.

-> Http2Client

A connected HTTP2 client.

-> Authority

The HTTP2-Authority portion of the URL (e.g., "dicioccio.fr:7777").

-> HeaderList

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

-> Timeout

Timeout in seconds.

-> Compression

An indication of the compression that you will be using and accepting. Compression should be per message, however a bug in gRPC-Go (to be confirmed) seems to turn message compression mandatory if advertised in the HTTP2 headers, even though the specification states that compression per message is optional irrespectively of headers.

-> RPCCall 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

Helpers

singleRequest :: (Service s, HasMethod s m) => RPC s m -> Compression -> MethodInput s m -> RPCCall (RawReply (MethodOutput s m)) Source #

gRPC call for an unary request.

streamReply :: (Service s, HasMethod s m, MethodStreamingType s m ~ ServerStreaming) => RPC s m -> Compression -> MethodInput s m -> (HeaderList -> Either String (MethodOutput s m) -> IO ()) -> RPCCall (HeaderList, HeaderList) Source #

gRPC call for Server Streaming.

streamRequest :: (Service s, HasMethod s m, MethodStreamingType s m ~ ClientStreaming) => RPC s m -> IO (Compression, Either StreamDone (MethodInput s m)) -> RPCCall (RawReply (MethodOutput s m)) Source #

gRPC call for Client Streaming.

data StreamDone Source #

Constructors

StreamDone 

Errors.

data InvalidState Source #

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

Constructors

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.