Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type UnaryHandler i o = Request -> i -> IO o
- type ServerStreamHandler i o a = Request -> i -> IO (a, ServerStream o a)
- newtype ServerStream o a = ServerStream {
- serverStreamNext :: a -> IO (Maybe (a, o))
- type ClientStreamHandler i o a = Request -> IO (a, ClientStream i o a)
- data ClientStream i o a = ClientStream {
- clientStreamHandler :: a -> i -> IO a
- clientStreamFinalizer :: a -> IO o
- type BiDiStreamHandler i o a = Request -> IO (a, BiDiStream i o a)
- data BiDiStep i o a
- = Abort
- | WaitInput !(a -> i -> IO a) !(a -> IO a)
- | WriteOutput !a o
- newtype BiDiStream i o a = BiDiStream {
- bidirNextStep :: a -> IO (BiDiStep i o a)
- unary :: (GRPCInput r i, GRPCOutput r o) => r -> UnaryHandler i o -> ServiceHandler
- serverStream :: (GRPCInput r i, GRPCOutput r o) => r -> ServerStreamHandler i o a -> ServiceHandler
- clientStream :: (GRPCInput r i, GRPCOutput r o) => r -> ClientStreamHandler i o a -> ServiceHandler
- bidiStream :: (GRPCInput r i, GRPCOutput r o) => r -> BiDiStreamHandler i o a -> ServiceHandler
- generalStream :: (GRPCInput r i, GRPCOutput r o) => r -> GeneralStreamHandler i o a b -> ServiceHandler
- handleUnary :: (GRPCInput r i, GRPCOutput r o) => r -> UnaryHandler i o -> WaiHandler
- handleServerStream :: (GRPCInput r i, GRPCOutput r o) => r -> ServerStreamHandler i o a -> WaiHandler
- handleClientStream :: (GRPCInput r i, GRPCOutput r o) => r -> ClientStreamHandler i o a -> WaiHandler
- handleBiDiStream :: (GRPCInput r i, GRPCOutput r o) => r -> BiDiStreamHandler i o a -> WaiHandler
- type GeneralStreamHandler i o a b = Request -> IO (a, IncomingStream i a, b, OutgoingStream o b)
- data IncomingStream i a = IncomingStream {
- incomingStreamHandler :: a -> i -> IO a
- incomingStreamFinalizer :: a -> IO ()
- newtype OutgoingStream o a = OutgoingStream {
- outgoingStreamNext :: a -> IO (Maybe (a, o))
- handleGeneralStream :: (GRPCInput r i, GRPCOutput r o) => r -> GeneralStreamHandler i o a b -> WaiHandler
- handleRequestChunksLoop :: Decoder (Either String a) -> (ByteString -> a -> IO b) -> IO b -> IO ByteString -> IO b
- errorOnLeftOver :: (a -> IO b) -> ByteString -> a -> IO b
Documentation
type UnaryHandler i o = Request -> i -> IO o Source #
Handy type to refer to Handler for unary
RPCs handler.
type ServerStreamHandler i o a = Request -> i -> IO (a, ServerStream o a) Source #
Handy type for 'server-streaming' RPCs.
We expect an implementation to:
- read the input request
- return an initial state and an state-passing action that the server code will call to fetch the output to send to the client (or close an a Nothing)
See ServerStream
for the type which embodies these requirements.
newtype ServerStream o a Source #
ServerStream | |
|
type ClientStreamHandler i o a = Request -> IO (a, ClientStream i o a) Source #
Handy type for 'client-streaming' RPCs.
We expect an implementation to:
- acknowledge a the new client stream by returning an initial state and two functions:
- a state-passing handler for new client message
- a state-aware handler for answering the client when it is ending its stream
See ClientStream
for the type which embodies these requirements.
data ClientStream i o a Source #
ClientStream | |
|
type BiDiStreamHandler i o a = Request -> IO (a, BiDiStream i o a) Source #
Handy type for 'bidirectional-streaming' RPCs.
We expect an implementation to: - acknowlege a new bidirection stream by returning an initial state and one functions: - a state-passing function that returns a single action step The action may be to - stop immediately - wait and handle some input with a callback and a finalizer (if the client closes the stream on its side) that may change the state - return a value and a new state
There is no way to stop locally (that would mean sending HTTP2 trailers) and keep receiving messages from the client.
newtype BiDiStream i o a Source #
BiDiStream | |
|
unary :: (GRPCInput r i, GRPCOutput r o) => r -> UnaryHandler i o -> ServiceHandler Source #
Construct a handler for handling a unary RPC.
serverStream :: (GRPCInput r i, GRPCOutput r o) => r -> ServerStreamHandler i o a -> ServiceHandler Source #
Construct a handler for handling a server-streaming RPC.
clientStream :: (GRPCInput r i, GRPCOutput r o) => r -> ClientStreamHandler i o a -> ServiceHandler Source #
Construct a handler for handling a client-streaming RPC.
bidiStream :: (GRPCInput r i, GRPCOutput r o) => r -> BiDiStreamHandler i o a -> ServiceHandler Source #
Construct a handler for handling a bidirectional-streaming RPC.
generalStream :: (GRPCInput r i, GRPCOutput r o) => r -> GeneralStreamHandler i o a b -> ServiceHandler Source #
Construct a handler for handling a bidirectional-streaming RPC.
handleUnary :: (GRPCInput r i, GRPCOutput r o) => r -> UnaryHandler i o -> WaiHandler Source #
Handle unary RPCs.
handleServerStream :: (GRPCInput r i, GRPCOutput r o) => r -> ServerStreamHandler i o a -> WaiHandler Source #
Handle Server-Streaming RPCs.
handleClientStream :: (GRPCInput r i, GRPCOutput r o) => r -> ClientStreamHandler i o a -> WaiHandler Source #
Handle Client-Streaming RPCs.
handleBiDiStream :: (GRPCInput r i, GRPCOutput r o) => r -> BiDiStreamHandler i o a -> WaiHandler Source #
Handle Bidirectional-Streaming RPCs.
type GeneralStreamHandler i o a b = Request -> IO (a, IncomingStream i a, b, OutgoingStream o b) Source #
A GeneralStreamHandler combining server and client asynchronous streams.
data IncomingStream i a Source #
Pair of handlers for reacting to incoming messages.
IncomingStream | |
|
newtype OutgoingStream o a Source #
Handler to decide on the next message (if any) to return.
OutgoingStream | |
|
handleGeneralStream :: (GRPCInput r i, GRPCOutput r o) => r -> GeneralStreamHandler i o a b -> WaiHandler Source #
Handler for the somewhat general case where two threads behave concurrently: - one reads messages from the client - one returns messages to the client
handleRequestChunksLoop Source #
:: Decoder (Either String a) | Message decoder. |
-> (ByteString -> a -> IO b) | Handler for a single message. The ByteString corresponds to leftover data. |
-> IO b | Handler for handling end-of-streams. |
-> IO ByteString | Action to retrieve the next chunk. |
-> IO b |
Helpers to consume input in chunks.
errorOnLeftOver :: (a -> IO b) -> ByteString -> a -> IO b Source #
Combinator around message handler to error on left overs.
This combinator ensures that, unless for client stream, an unparsed piece of data with a correctly-read message is treated as an error.