Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ganeti.UDSServer
Description
Implementation of the Ganeti Unix Domain Socket JSON server interface.
Synopsis
- data ConnectConfig = ConnectConfig {}
- data ServerConfig = ServerConfig {}
- data Client
- data Server
- data RecvResult
- = RecvConnClosed
- | RecvError String
- | RecvOk String
- data MsgKeys
- strOfKey :: MsgKeys -> String
- openClientSocket :: Int -> FilePath -> IO Handle
- closeClientSocket :: Handle -> IO ()
- openServerSocket :: FilePath -> IO Socket
- closeServerSocket :: Socket -> FilePath -> IO ()
- acceptSocket :: Socket -> IO Handle
- connectClient :: ConnectConfig -> Int -> FilePath -> IO Client
- connectServer :: ServerConfig -> Bool -> FilePath -> IO Server
- pipeClient :: ConnectConfig -> IO (Client, Client)
- acceptClient :: Server -> IO Client
- closeClient :: Client -> IO ()
- clientToFd :: Client -> IO (Fd, Fd)
- clientToHandle :: Client -> (Handle, Handle)
- closeServer :: MonadBase IO m => Server -> m ()
- buildResponse :: Bool -> JSValue -> String
- parseResponse :: String -> ErrorResult JSValue
- buildCall :: (JSON mth, JSON args) => mth -> args -> String
- parseCall :: (JSON mth, JSON args) => String -> Result (mth, args)
- recvMsg :: Client -> IO String
- recvMsgExt :: Client -> IO RecvResult
- sendMsg :: Client -> String -> IO ()
- data Handler i m o = Handler {
- hParse :: JSValue -> JSValue -> Result i
- hInputLogShort :: i -> String
- hInputLogLong :: i -> String
- hExec :: i -> HandlerResult m o
- type HandlerResult m o = m (Bool, GenericResult GanetiException o)
- listener :: (JSON o, MonadBaseControl IO m, MonadLog m) => Handler i m o -> Server -> m ()
Documentation
data ConnectConfig #
Constructors
ConnectConfig | |
data ServerConfig #
Constructors
ServerConfig | |
Fields |
A client encapsulation. Note that it has separate read and write handle. For sockets it is the same handle. It is required for bi-directional inter-process pipes though.
data RecvResult #
Result of receiving a message from the socket.
Constructors
RecvConnClosed | Connection closed |
RecvError String | Any other error |
RecvOk String | Successfull receive |
Instances
Show RecvResult # | |
Defined in Ganeti.UDSServer Methods showsPrec :: Int -> RecvResult -> ShowS show :: RecvResult -> String showList :: [RecvResult] -> ShowS | |
Eq RecvResult # | |
Defined in Ganeti.UDSServer |
Unix sockets
Arguments
:: Int | connection timeout |
-> FilePath | socket path |
-> IO Handle |
Creates a Unix socket and connects it to the specified path
,
where timeout
specifies the connection timeout.
closeClientSocket :: Handle -> IO () #
Closes the handle. Performing the operation on a handle that has already been closed has no effect; doing so is not an error. All other operations on a closed handle will fail.
openServerSocket :: FilePath -> IO Socket #
Creates a Unix socket and binds it to the specified path
.
closeServerSocket :: Socket -> FilePath -> IO () #
acceptSocket :: Socket -> IO Handle #
Client and server
Arguments
:: ConnectConfig | configuration for the client |
-> Int | connection timeout |
-> FilePath | socket path |
-> IO Client |
Connects to the master daemon and returns a Client.
connectServer :: ServerConfig -> Bool -> FilePath -> IO Server #
Creates and returns a server endpoint.
pipeClient :: ConnectConfig -> IO (Client, Client) #
Creates a new bi-directional client pipe. The two returned clients talk to each other through the pipe.
acceptClient :: Server -> IO Client #
Accepts a client
closeClient :: Client -> IO () #
Closes the client socket. Performing the operation on a client that has already been closed has no effect; doing so is not an error. All other operations on a closed client will fail with an exception.
clientToFd :: Client -> IO (Fd, Fd) #
Extracts the read (the first) and the write (the second) file descriptor
of a client. This closes the underlying Handle
s, therefore the original
client is closed and unusable after the call.
The purpose of this function is to keep the communication channel open,
while replacing a Client
with some other means.
clientToHandle :: Client -> (Handle, Handle) #
Extracts the read (first) and the write (second) handles of a client. The purpose of this function is to allow using a client's handles as input/output streams elsewhere.
closeServer :: MonadBase IO m => Server -> m () #
Closes a server endpoint.
Arguments
:: Bool | Success |
-> JSValue | The arguments |
-> String | The serialized form |
Serialize the response to String.
parseResponse :: String -> ErrorResult JSValue #
Check that luxi responses contain the required keys and that the call was successful.
Arguments
:: (JSON mth, JSON args) | |
=> mth | The method |
-> args | The arguments |
-> String | The serialized form |
Serialize a request to String.
parseCall :: (JSON mth, JSON args) => String -> Result (mth, args) #
Parse the required keys out of a call.
recvMsgExt :: Client -> IO RecvResult #
Extended wrapper over recvMsg.
Client handler
Constructors
Handler | |
Fields
|
type HandlerResult m o = m (Bool, GenericResult GanetiException o) #