mu-grpc-server-0.1.0.0: gRPC servers for Mu definitions

Safe HaskellNone
LanguageHaskell2010

Mu.GRpc.Server

Contents

Description

This module allows you to server a Mu Server as a WAI Application using gRPC as transport layer.

The simples way is to use runGRpcApp, all other variants provide more control over the settings.

Synopsis

Run a Server directly

runGRpcApp :: (KnownName name, KnownName (FindPackageName anns), GRpcMethodHandlers ServerErrorIO methods handlers) => Port -> ServerT Maybe (Service name anns methods) ServerErrorIO handlers -> IO () Source #

Run a Mu Server on the given port.

runGRpcAppTrans :: (KnownName name, KnownName (FindPackageName anns), GRpcMethodHandlers m methods handlers) => Port -> (forall a. m a -> ServerErrorIO a) -> ServerT Maybe (Service name anns methods) m handlers -> IO () Source #

Run a Mu Server on the given port.

runGRpcAppSettings :: (KnownName name, KnownName (FindPackageName anns), GRpcMethodHandlers m methods handlers) => Settings -> (forall a. m a -> ServerErrorIO a) -> ServerT Maybe (Service name anns methods) m handlers -> IO () Source #

Run a Mu Server using the given Settings.

Go to Warp to declare Settings.

data Settings #

Various Warp server settings. This is purposely kept as an abstract data type so that new settings can be added without breaking backwards compatibility. In order to create a Settings value, use defaultSettings and the various 'set' functions to modify individual fields. For example:

setTimeout 20 defaultSettings

runGRpcAppTLS :: (KnownName name, KnownName (FindPackageName anns), GRpcMethodHandlers m methods handlers) => TLSSettings -> Settings -> (forall a. m a -> ServerErrorIO a) -> ServerT Maybe (Service name anns methods) m handlers -> IO () Source #

Run a Mu Server using the given TLSSettings and Settings.

Go to WarpTLS to declare TLSSettings and to Warp to declare Settings.

data TLSSettings #

Settings for WarpTLS.

Convert a Server into a WAI application

gRpcApp :: (KnownName name, KnownName (FindPackageName anns), GRpcMethodHandlers ServerErrorIO methods handlers) => ServerT Maybe (Service name anns methods) ServerErrorIO handlers -> Application Source #

Turn a Mu Server into a WAI Application.

These Applications can be later combined using, for example, wai-routes, or you can add middleware from wai-extra, among others.

Raise errors as exceptions in IO

raiseErrors :: MonadIO m => ServerErrorIO a -> m a Source #

Raises errors from ServerErrorIO as exceptions in a monad which supports IO.

This function is useful to interoperate with other libraries which cannot handle the additional error layer. In particular, with Conduit, as witnessed by liftServerConduit.

liftServerConduit :: MonadIO m => ConduitT a b ServerErrorIO r -> ConduitT a b m r Source #

Turns a Conduit working on ServerErrorIO into any other base monad which supports IO, by raising any error as an exception.

This function is useful to interoperate with libraries which generate Conduits with other base monads, such as persistent.