greskell-websocket-0.1.1.2: Haskell client for Gremlin Server using WebSocket serializer

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Network.Greskell.WebSocket.Connection

Contents

Description

 
Synopsis

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.

type Host = String Source #

Host name or an IP address.

type Port = Int Source #

TCP port number.

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 ResponseMessages from this object.

Type s is the body of the response.

Instances
Functor ResponseHandle Source # 
Instance details

Defined in Network.Greskell.WebSocket.Connection.Impl

Methods

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.

drainResponses :: ResponseHandle s -> IO () Source #

Similar to slurpResponses, but this function discards the responses.

Since: greskell-websocket-0.1.1.0

Exceptions

data GeneralException Source #

Exception general to a Connection. It's not related to specific requests.

Constructors

UnexpectedRequestId UUID

Server sends a ResponseMessage with unknown requestId, which is kept in this exception.

ResponseParseFailure String

The Connection fails to parse a data from the server. The error message is kept in this exception.

data RequestException Source #

An exception related to a specific request.

Constructors

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 responseTimeout.