grapesy
Safe HaskellNone
LanguageHaskell2010

Network.GRPC.Server.Run

Description

Convenience functions for running a HTTP2 server

Intended for unqualified import.

Synopsis

Configuration

data ServerConfig Source #

Server configuration

Describes the configuration of both an insecure server and a secure server. See the documentation of runServer for a description of what servers will result from various configurations.

Constructors

ServerConfig 

Fields

Instances

Instances details
Generic ServerConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

Associated Types

type Rep ServerConfig 
Instance details

Defined in Network.GRPC.Server.Run

type Rep ServerConfig = D1 ('MetaData "ServerConfig" "Network.GRPC.Server.Run" "grapesy-1.0.1-inplace" 'False) (C1 ('MetaCons "ServerConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "serverInsecure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe InsecureConfig)) :*: S1 ('MetaSel ('Just "serverSecure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe SecureConfig))))
Show ServerConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

type Rep ServerConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

type Rep ServerConfig = D1 ('MetaData "ServerConfig" "Network.GRPC.Server.Run" "grapesy-1.0.1-inplace" 'False) (C1 ('MetaCons "ServerConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "serverInsecure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe InsecureConfig)) :*: S1 ('MetaSel ('Just "serverSecure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe SecureConfig))))

data InsecureConfig Source #

Offer insecure connection (no TLS)

Constructors

InsecureConfig

Insecure TCP connection

Fields

InsecureUnix

Insecure (but local) Unix domain socket connection

Fields

Instances

Instances details
Generic InsecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

Associated Types

type Rep InsecureConfig 
Instance details

Defined in Network.GRPC.Server.Run

type Rep InsecureConfig = D1 ('MetaData "InsecureConfig" "Network.GRPC.Server.Run" "grapesy-1.0.1-inplace" 'False) (C1 ('MetaCons "InsecureConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "insecureHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe HostName)) :*: S1 ('MetaSel ('Just "insecurePort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PortNumber)) :+: C1 ('MetaCons "InsecureUnix" 'PrefixI 'True) (S1 ('MetaSel ('Just "insecurePath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))
Show InsecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

type Rep InsecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

type Rep InsecureConfig = D1 ('MetaData "InsecureConfig" "Network.GRPC.Server.Run" "grapesy-1.0.1-inplace" 'False) (C1 ('MetaCons "InsecureConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "insecureHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe HostName)) :*: S1 ('MetaSel ('Just "insecurePort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PortNumber)) :+: C1 ('MetaCons "InsecureUnix" 'PrefixI 'True) (S1 ('MetaSel ('Just "insecurePath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))

data SecureConfig Source #

Offer secure connection (over TLS)

Constructors

SecureConfig 

Fields

Instances

Instances details
Generic SecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

Associated Types

type Rep SecureConfig 
Instance details

Defined in Network.GRPC.Server.Run

Show SecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

type Rep SecureConfig Source # 
Instance details

Defined in Network.GRPC.Server.Run

Simple interface

runServer :: HTTP2Settings -> ServerConfig -> Server -> IO () Source #

Run a Server with the given ServerConfig.

If both configurations are disabled, runServer will simply immediately return. If both configurations are enabled, then two servers will be run concurrently; one with the insecure configuration and the other with the secure configuration. Obviously, if only one of the configurations is enabled, then just that server will be run.

See also runServerWithHandlers, which handles the creation of the Server for you.

runServerWithHandlers :: ServerParams -> ServerConfig -> [SomeRpcHandler IO] -> IO () Source #

Convenience function that combines runServer with mkGrpcServer

NOTE: If you want to override the HTTP2Settings, use runServer instead.

Full interface

forkServer :: HTTP2Settings -> ServerConfig -> Server -> (RunningServer -> IO a) -> IO a Source #

Start the server

waitServer :: RunningServer -> IO () Source #

IO version of waitServerSTM that rethrows exceptions

waitServerSTM :: RunningServer -> STM (Either SomeException (), Either SomeException ()) Source #

Wait for the server to terminate

Returns the results of the insecure and secure servers separately. Note that under normal circumstances the server never terminates.

getInsecureSocket :: RunningServer -> STM Socket Source #

Get the socket used by the insecure server

The socket is created as the server initializes; this function will block until that is complete. However:

  • If the server throws an exception, that exception is rethrown here.
  • If the server has already terminated, we throw ServerTerminated
  • If the insecure server was not enabled, it is considered to have terminated immediately and the same ServerTerminated exception is thrown.

getSecureSocket :: RunningServer -> STM Socket Source #

Get the socket used by the secure server

Similar remarks apply as for getInsecureSocket.

getServerSocket :: RunningServer -> STM Socket Source #

Get "the" socket associated with the server

Precondition: only one server must be enabled (secure or insecure).

getServerPort :: RunningServer -> IO PortNumber Source #

Get "the" port number used by the server

Precondition: only one server must be enabled (secure or insecure).

Exceptions