| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Network.GRPC.Client
Description
A module adding support for gRPC over HTTP2.
Synopsis
- data RPC s (m :: Symbol) = RPC
 - type Authority = HeaderValue
 - newtype Timeout = Timeout Int
 - open :: (Service s, HasMethod s m) => Http2Client -> Authority -> HeaderList -> Timeout -> Encoding -> Decoding -> RPCCall s m a -> IO (Either TooMuchConcurrency a)
 - type RawReply a = Either ErrorCode (CIHeaderList, Maybe CIHeaderList, Either String a)
 - singleRequest :: (Service s, HasMethod s m) => RPC s m -> MethodInput s m -> RPCCall s m (RawReply (MethodOutput s m))
 - streamReply :: (Service s, HasMethod s m, MethodStreamingType s m ~ ServerStreaming) => RPC s m -> a -> MethodInput s m -> (a -> HeaderList -> MethodOutput s m -> IO a) -> RPCCall s m (a, HeaderList, HeaderList)
 - streamRequest :: (Service s, HasMethod s m, MethodStreamingType s m ~ ClientStreaming) => RPC s m -> a -> (a -> IO (a, Either StreamDone (CompressMode, MethodInput s m))) -> RPCCall s m (a, RawReply (MethodOutput s m))
 - data CompressMode
 - data StreamDone = StreamDone
 - data InvalidState = InvalidState String
 - data StreamReplyDecodingError = StreamReplyDecodingError String
 - data UnallowedPushPromiseReceived = UnallowedPushPromiseReceived
 - data Compression
 - gzip :: Compression
 - uncompressed :: Compression
 
Building blocks.
type Authority = HeaderValue #
The HTTP2-Authority portion of an URL (e.g., "dicioccio.fr:7777").
Arguments
| :: (Service s, HasMethod s m) | |
| => 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.  | 
| -> 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 (CIHeaderList, Maybe CIHeaderList, 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
Arguments
| :: (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.
Arguments
| :: (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.
Arguments
| :: (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 CompressMode Source #
Constructors
| Compressed | |
| Uncompressed | 
data StreamDone Source #
Constructors
| StreamDone | 
Errors.
data InvalidState Source #
Exception raised when a ServerStreaming RPC results in an invalid state machine.
Constructors
| InvalidState String | 
Instances
| Show InvalidState Source # | |
Defined in Network.GRPC.Client Methods showsPrec :: Int -> InvalidState -> ShowS # show :: InvalidState -> String # showList :: [InvalidState] -> ShowS #  | |
| Exception InvalidState Source # | |
Defined in Network.GRPC.Client Methods toException :: InvalidState -> SomeException # fromException :: SomeException -> Maybe InvalidState # displayException :: InvalidState -> String #  | |
data StreamReplyDecodingError Source #
Exception raised when a ServerStreaming RPC results in a decoding error.
Constructors
| StreamReplyDecodingError String | 
Instances
| Show StreamReplyDecodingError Source # | |
Defined in Network.GRPC.Client Methods showsPrec :: Int -> StreamReplyDecodingError -> ShowS # show :: StreamReplyDecodingError -> String # showList :: [StreamReplyDecodingError] -> ShowS #  | |
| Exception StreamReplyDecodingError Source # | |
Defined in Network.GRPC.Client  | |
data UnallowedPushPromiseReceived Source #
gRPC disables HTTP2 push-promises.
If a server attempts to send push-promises, this exception will be raised.
Constructors
| UnallowedPushPromiseReceived | 
Instances
| Show UnallowedPushPromiseReceived Source # | |
Defined in Network.GRPC.Client Methods showsPrec :: Int -> UnallowedPushPromiseReceived -> ShowS # show :: UnallowedPushPromiseReceived -> String # showList :: [UnallowedPushPromiseReceived] -> ShowS #  | |
| Exception UnallowedPushPromiseReceived Source # | |
Defined in Network.GRPC.Client  | |
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.
Do not compress.