Safe Haskell | None |
---|
- data Client i o m r
- run :: forall i o m r. (Serializable IO i, Serializable IO o, MonadIO m, Applicative m, MonadBaseControl IO m) => Settings -> Client i o m r -> m (Either Failure r)
- request :: (Serializable IO i, Serializable IO o, MonadIO m, Applicative m) => i -> Client i o m o
- type Settings = (UserProtocolSignature, URL)
- type UserProtocolSignature = ByteString
- data URL
- = Socket FilePath
- | Host Text Int Credentials
- type Credentials = Maybe ByteString
- data Failure
- = UnreachableURL
- | ServerIsBusy
- | Unauthenticated
- | ConnectionInterrupted
- | TimeoutReached Int
- | ProtocolVersionMismatch Int Int
- | UserProtocolSignatureMismatch ByteString ByteString
- | CorruptRequest Text
Control
A monad transformer for performing actions on client-side.
Supports custom protocols with i
being the type of the client request and
o
- the server's response.
MonadBase IO m => MonadBase IO (Client i o m) | |
MonadBaseControl IO m => MonadBaseControl IO (Client i o m) | |
Monad m => MonadError Failure (Client i o m) | |
MonadTrans (Client i o) | |
MonadTransControl (Client i o) | |
Monad m => Monad (Client i o m) | |
Monad m => Functor (Client i o m) | |
Monad m => Applicative (Client i o m) | |
MonadIO m => MonadIO (Client i o m) |
run :: forall i o m r. (Serializable IO i, Serializable IO o, MonadIO m, Applicative m, MonadBaseControl IO m) => Settings -> Client i o m r -> m (Either Failure r)Source
Run Client
in the base monad.
Requires the base monad to have a MonadBaseControl
instance for IO
.
request :: (Serializable IO i, Serializable IO o, MonadIO m, Applicative m) => i -> Client i o m oSource
Send a request i
and receive a response o
.
Settings
type Settings = (UserProtocolSignature, URL)Source
Settings of Client
.
type UserProtocolSignature = ByteStringSource
A unique identification of user's protocol version used for checking of protocol versions mismatch between client and server. It can be simply a user-supplied version number or a hash or a serialization of the representation of a type used for protocol, which can be generated using such library as type-structure.
Location of the server.
Socket FilePath | Path to the socket-file. |
Host Text Int Credentials | Host name, port and credentials. |
type Credentials = Maybe ByteStringSource
Either a plain ASCII password or an encoding of some data, e.g. an MD5 hash of a username-password pair or just a password. In more involved scenarios you can mix in serialization, e.g. a serialized pair of username and a hash of just the password.
Nothing
means anonymous.
Failure
UnreachableURL | Unable to connect to the provided url. |
ServerIsBusy | Server has too many connections already. It's suggested to retry later. |
Unauthenticated | Incorrect credentials. |
ConnectionInterrupted | Connection got interrupted for some reason. |
TimeoutReached Int | A timeout of communication with server reached. |
ProtocolVersionMismatch Int Int | A mismatch of the internal protocol versions on client and server. First is the version on the client, second is the version on the server. |
UserProtocolSignatureMismatch ByteString ByteString | A mismatch of the user-supplied versions of custom protocol on client and server. First is the version on the client, second is the version on the server. |
CorruptRequest Text | Server reports that it was unable to deserialize the request. This is only expected to happen in case of user's protocol mismatch. |