grpc-haskell-0.1.0: Haskell implementation of gRPC layered on shared C library.
Safe HaskellNone
LanguageHaskell2010

Network.GRPC.HighLevel.Client

Synopsis

Documentation

data ClientRequest (streamType :: GRPCMethodType) request response where Source #

Constructors

ClientNormalRequest :: request -> TimeoutSeconds -> MetadataMap -> ClientRequest 'Normal request response 
ClientWriterRequest :: TimeoutSeconds -> MetadataMap -> (StreamSend request -> IO ()) -> ClientRequest 'ClientStreaming request response 
ClientReaderRequest :: request -> TimeoutSeconds -> MetadataMap -> (ClientCall -> MetadataMap -> StreamRecv response -> IO ()) -> ClientRequest 'ServerStreaming request response

The final field will be invoked once, and it should repeatedly invoke its final argument (of type (StreamRecv response)) in order to obtain the streaming response incrementally.

ClientBiDiRequest :: TimeoutSeconds -> MetadataMap -> (ClientCall -> MetadataMap -> StreamRecv response -> StreamSend request -> WritesDone -> IO ()) -> ClientRequest 'BiDiStreaming request response 

data GRPCMethodType #

Models the four types of RPC call supported by gRPC (and correspond to DataKinds phantom types on RegisteredMethods).

newtype MetadataMap #

Represents metadata for a given RPC, consisting of key-value pairs. Keys are allowed to be repeated. Since repeated keys are unlikely in practice, the IsList instance uses key-value pairs as items. For example, fromList [("key1","val1"),("key2","val2"),("key1","val3")].

data RegisteredMethod (mt :: GRPCMethodType) request response Source #

Instances

Instances details
Show (RegisteredMethod mt request response) Source # 
Instance details

Defined in Network.GRPC.HighLevel.Client

Methods

showsPrec :: Int -> RegisteredMethod mt request response -> ShowS #

show :: RegisteredMethod mt request response -> String #

showList :: [RegisteredMethod mt request response] -> ShowS #

type StreamSend a = a -> IO (Either GRPCIOError ()) #

data Client #

Represents the context needed to perform client-side gRPC operations.

data ClientConfig #

Configuration necessary to set up a client.

Constructors

ClientConfig 

Fields

data ClientSSLConfig #

SSL configuration for the client. It's perfectly acceptable for both fields to be Nothing, in which case default fallbacks will be used for the server root cert.

Constructors

ClientSSLConfig 

Fields

newtype Host #

Constructors

Host 

Fields

Instances

Instances details
Eq Host 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

(==) :: Host -> Host -> Bool #

(/=) :: Host -> Host -> Bool #

Show Host 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

showsPrec :: Int -> Host -> ShowS #

show :: Host -> String #

showList :: [Host] -> ShowS #

IsString Host 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

fromString :: String -> Host #

newtype Port #

Constructors

Port 

Fields

Instances

Instances details
Eq Port 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

(==) :: Port -> Port -> Bool #

(/=) :: Port -> Port -> Bool #

Num Port 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

(+) :: Port -> Port -> Port #

(-) :: Port -> Port -> Port #

(*) :: Port -> Port -> Port #

negate :: Port -> Port #

abs :: Port -> Port #

signum :: Port -> Port #

fromInteger :: Integer -> Port #

Show Port 
Instance details

Defined in Network.GRPC.LowLevel.Call

Methods

showsPrec :: Int -> Port -> ShowS #

show :: Port -> String #

showList :: [Port] -> ShowS #

clientRequest :: (Message request, Message response) => Client -> RegisteredMethod streamType request response -> ClientRequest streamType request response -> IO (ClientResult streamType response) Source #

Client utility functions

acquireClient Source #

Arguments

:: ClientConfig

The client configuration (host, port, SSL settings, etc)

-> (Client -> IO (ServiceClient service))

The client implementation (typically generated)

-> Managed (ServiceClient service) 

simplifyServerStreaming Source #

Arguments

:: TimeoutSeconds

RPC call timeout, in seconds

-> MetadataMap

RPC call metadata

-> (ClientError -> IO StatusDetails)

Handler for client errors

-> (StatusCode -> StatusDetails -> IO StatusDetails)

Handler for non-StatusOk response

-> (ClientRequest 'ServerStreaming request response -> IO (ClientResult 'ServerStreaming response))

Endpoint implementation (typically generated by grpc-haskell)

-> request

Request payload

-> (ClientCall -> MetadataMap -> StreamRecv response -> IO ())

Stream handler; note that the StreamRecv action must be called repeatedly in order to consume the stream

-> IO StatusDetails 

A utility for simplifying server-streaming gRPC client requests; you can use this to avoid ClientRequest and ClientResult pattern-matching boilerplate at call sites.

simplifyUnary Source #

Arguments

:: TimeoutSeconds

RPC call timeout, in seconds

-> MetadataMap

RPC call metadata

-> (ClientError -> IO (response, StatusDetails))

Handler for client errors

-> (response -> StatusCode -> StatusDetails -> IO (response, StatusDetails))

Handler for non-StatusOK responses

-> (ClientRequest 'Normal request response -> IO (ClientResult 'Normal response))

Endpoint implementation (typically generated by grpc-haskell)

-> request -> IO (response, StatusDetails)

The simplified happy-path (StatusOk) unary call action

A utility for simplifying unary gRPC client requests; you can use this to avoid ClientRequest and ClientResult pattern-matching boilerplate at call sites.