Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- connect :: Settings s -> Host -> Port -> IO (Connection s)
- close :: Connection s -> IO ()
- data Connection s
- type Host = String
- type Port = Int
- module Network.Greskell.WebSocket.Connection.Settings
- sendRequest :: Operation o => Connection s -> o -> IO (ResponseHandle s)
- sendRequest' :: Connection s -> RequestMessage -> IO (ResponseHandle s)
- data ResponseHandle s
- nextResponse :: ResponseHandle s -> IO (Maybe (ResponseMessage s))
- nextResponseSTM :: ResponseHandle s -> STM (Maybe (ResponseMessage s))
- slurpResponses :: ResponseHandle s -> IO (Vector (ResponseMessage s))
- drainResponses :: ResponseHandle s -> IO ()
- data GeneralException
- data RequestException
Make a Connection
connect :: Settings s -> Host -> Port -> IO (Connection s) Source #
Make a Connection
to a Gremlin Server.
If it fails to connect to the specified server, it throws an exception.
close :: Connection s -> IO () Source #
Close the Connection
.
If there are pending requests in the Connection
, close
function
blocks for them to complete or time out.
Calling close
on a Connection
already closed (or waiting to
close) does nothing.
data Connection s Source #
A WebSocket connection to a Gremlin Server.
Type s
is the body of Response, as in ResponseMessage
.
Settings for Connection
Make a request
sendRequest :: Operation o => Connection s -> o -> IO (ResponseHandle s) Source #
Make a RequestMessage
from an Operation
and send it.
Usually this function does not throw any exception. Exceptions
about sending requests are reported when you operate on
ResponseHandle
.
sendRequest' :: Connection s -> RequestMessage -> IO (ResponseHandle s) Source #
Like sendRequest
, but you can pass a RequestMessage
directly
to this function.
data ResponseHandle s Source #
A handle associated in a Connection
for a pair of request and
response. You can retrieve ResponseMessage
s from this object.
Type s
is the body of the response.
Instances
Functor ResponseHandle Source # | |
Defined in Network.Greskell.WebSocket.Connection.Impl fmap :: (a -> b) -> ResponseHandle a -> ResponseHandle b # (<$) :: a -> ResponseHandle b -> ResponseHandle a # |
nextResponse :: ResponseHandle s -> IO (Maybe (ResponseMessage s)) Source #
Get a ResponseMessage
from ResponseHandle
. If you have
already got all responses, it returns Nothing
. This function may
block for a new ResponseMessage
to come.
On error, it may throw all sorts of exceptions including
RequestException
.
nextResponseSTM :: ResponseHandle s -> STM (Maybe (ResponseMessage s)) Source #
STM
version of nextResponse
.
slurpResponses :: ResponseHandle s -> IO (Vector (ResponseMessage s)) Source #
Get all remaining ResponseMessage
s from ResponseHandle
.
drainResponses :: ResponseHandle s -> IO () Source #
Similar to slurpResponses
, but this function discards the
responses.
Since: 0.1.1.0
Exceptions
data GeneralException Source #
Exception general to a Connection
. It's not related to specific
requests.
UnexpectedRequestId UUID | Server sends a |
ResponseParseFailure String | The |
Instances
Exception GeneralException Source # | |
Show GeneralException Source # | |
Defined in Network.Greskell.WebSocket.Connection.Type showsPrec :: Int -> GeneralException -> ShowS # show :: GeneralException -> String # showList :: [GeneralException] -> ShowS # | |
Eq GeneralException Source # | |
Defined in Network.Greskell.WebSocket.Connection.Type (==) :: GeneralException -> GeneralException -> Bool # (/=) :: GeneralException -> GeneralException -> Bool # |
data RequestException Source #
An exception related to a specific request.
AlreadyClosed | The connection is already closed before it sends the request. |
ServerClosed | The server closed the connection before it sends response for this request. |
DuplicateRequestId UUID | The requestId (kept in this object) is already pending in the connection. |
ResponseTimeout | The server fails to send ResponseMessages within
|
Instances
Exception RequestException Source # | |
Show RequestException Source # | |
Defined in Network.Greskell.WebSocket.Connection.Impl showsPrec :: Int -> RequestException -> ShowS # show :: RequestException -> String # showList :: [RequestException] -> ShowS # | |
Eq RequestException Source # | |
Defined in Network.Greskell.WebSocket.Connection.Impl (==) :: RequestException -> RequestException -> Bool # (/=) :: RequestException -> RequestException -> Bool # |