-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell client for Gremlin Server using WebSocket serializer -- -- Haskell client for Gremlin Server using WebSocket serializer. -- See README.md for detail. -- -- This package is based on greskell-core, and best used with -- greskell package. @package greskell-websocket @version 1.0.0.1 module Network.Greskell.WebSocket.Request.Common -- | Class of operation objects. class Operation o -- | "processor" field. opProcessor :: Operation o => o -> Text -- | "op" field. opName :: Operation o => o -> Text -- | "args" field. opArgs :: Operation o => o -> Object -- | Possible SASL mechanisms. data SASLMechanism -- | "PLAIN" SASL SASLPlain :: SASLMechanism -- | "GSSAPI" SASL SASLGSSAPI :: SASLMechanism -- | A raw ByteString encoded to/decoded from a base64 text. -- -- ToJSON instance encodes the raw ByteString to a -- base64-encoded Text. FromJSON is its inverse. newtype Base64 Base64 :: ByteString -> Base64 [unByte64] :: Base64 -> ByteString instance GHC.Show.Show Network.Greskell.WebSocket.Request.Common.SASLMechanism instance GHC.Classes.Ord Network.Greskell.WebSocket.Request.Common.SASLMechanism instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Common.SASLMechanism instance GHC.Enum.Enum Network.Greskell.WebSocket.Request.Common.SASLMechanism instance GHC.Enum.Bounded Network.Greskell.WebSocket.Request.Common.SASLMechanism instance GHC.Show.Show Network.Greskell.WebSocket.Request.Common.Base64 instance GHC.Classes.Ord Network.Greskell.WebSocket.Request.Common.Base64 instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Common.Base64 instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Common.Base64 instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Common.Base64 instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Common.SASLMechanism instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Common.SASLMechanism instance (Network.Greskell.WebSocket.Request.Common.Operation a, Network.Greskell.WebSocket.Request.Common.Operation b) => Network.Greskell.WebSocket.Request.Common.Operation (Data.Either.Either a b) module Network.Greskell.WebSocket.Request -- | RequestMessage to a Gremlin Server. See -- http://tinkerpop.apache.org/docs/current/dev/provider/. data RequestMessage RequestMessage :: !UUID -> !Text -> !Text -> !Object -> RequestMessage [$sel:requestId:RequestMessage] :: RequestMessage -> !UUID [$sel:op:RequestMessage] :: RequestMessage -> !Text [$sel:processor:RequestMessage] :: RequestMessage -> !Text [$sel:args:RequestMessage] :: RequestMessage -> !Object -- | Class of operation objects. class Operation o -- | "processor" field. opProcessor :: Operation o => o -> Text -- | "op" field. opName :: Operation o => o -> Text -- | "args" field. opArgs :: Operation o => o -> Object -- | Convert an Operation object to RequestMessage. toRequestMessage :: Operation o => UUID -> o -> RequestMessage -- | Create a RequestMessage from an Operation object. The -- $sel:requestId:RequestMessage is generated by the random number -- generator of the system. makeRequestMessage :: Operation o => o -> IO RequestMessage instance GHC.Show.Show Network.Greskell.WebSocket.Request.RequestMessage instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.RequestMessage instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.RequestMessage instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.RequestMessage instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.RequestMessage module Network.Greskell.WebSocket.Request.Session data OpAuthentication OpAuthentication :: !Maybe Int -> !Base64 -> !SASLMechanism -> OpAuthentication [$sel:batchSize:OpAuthentication] :: OpAuthentication -> !Maybe Int [$sel:sasl:OpAuthentication] :: OpAuthentication -> !Base64 [$sel:saslMechanism:OpAuthentication] :: OpAuthentication -> !SASLMechanism type SessionID = UUID data OpEval OpEval :: !Maybe Int -> !Text -> !Maybe Object -> !Maybe Text -> !Maybe (HashMap Text Text) -> !Maybe Int -> !SessionID -> !Maybe Bool -> OpEval [$sel:batchSize:OpEval] :: OpEval -> !Maybe Int [$sel:gremlin:OpEval] :: OpEval -> !Text [$sel:bindings:OpEval] :: OpEval -> !Maybe Object [$sel:language:OpEval] :: OpEval -> !Maybe Text [$sel:aliases:OpEval] :: OpEval -> !Maybe (HashMap Text Text) [$sel:scriptEvaluationTimeout:OpEval] :: OpEval -> !Maybe Int [$sel:session:OpEval] :: OpEval -> !SessionID [$sel:manageTransaction:OpEval] :: OpEval -> !Maybe Bool data OpClose OpClose :: !Maybe Int -> !SessionID -> !Maybe Bool -> OpClose [$sel:batchSize:OpClose] :: OpClose -> !Maybe Int [$sel:session:OpClose] :: OpClose -> !SessionID [$sel:force:OpClose] :: OpClose -> !Maybe Bool instance GHC.Show.Show Network.Greskell.WebSocket.Request.Session.OpAuthentication instance GHC.Classes.Ord Network.Greskell.WebSocket.Request.Session.OpAuthentication instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.Session.OpAuthentication instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Session.OpAuthentication instance GHC.Show.Show Network.Greskell.WebSocket.Request.Session.OpEval instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.Session.OpEval instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Session.OpEval instance GHC.Show.Show Network.Greskell.WebSocket.Request.Session.OpClose instance GHC.Classes.Ord Network.Greskell.WebSocket.Request.Session.OpClose instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.Session.OpClose instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Session.OpClose instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Session.OpClose instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Session.OpClose instance Network.Greskell.WebSocket.Request.Common.Operation Network.Greskell.WebSocket.Request.Session.OpClose instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Session.OpEval instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Session.OpEval instance Network.Greskell.WebSocket.Request.Common.Operation Network.Greskell.WebSocket.Request.Session.OpEval instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Session.OpAuthentication instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Session.OpAuthentication instance Network.Greskell.WebSocket.Request.Common.Operation Network.Greskell.WebSocket.Request.Session.OpAuthentication module Network.Greskell.WebSocket.Request.Standard data OpAuthentication OpAuthentication :: !Maybe Int -> !Base64 -> !SASLMechanism -> OpAuthentication [$sel:batchSize:OpAuthentication] :: OpAuthentication -> !Maybe Int [$sel:sasl:OpAuthentication] :: OpAuthentication -> !Base64 [$sel:saslMechanism:OpAuthentication] :: OpAuthentication -> !SASLMechanism data OpEval OpEval :: !Maybe Int -> !Text -> !Maybe Object -> !Maybe Text -> !Maybe (HashMap Text Text) -> !Maybe Int -> OpEval [$sel:batchSize:OpEval] :: OpEval -> !Maybe Int [$sel:gremlin:OpEval] :: OpEval -> !Text [$sel:bindings:OpEval] :: OpEval -> !Maybe Object [$sel:language:OpEval] :: OpEval -> !Maybe Text [$sel:aliases:OpEval] :: OpEval -> !Maybe (HashMap Text Text) [$sel:scriptEvaluationTimeout:OpEval] :: OpEval -> !Maybe Int instance GHC.Show.Show Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance GHC.Classes.Ord Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance GHC.Show.Show Network.Greskell.WebSocket.Request.Standard.OpEval instance GHC.Generics.Generic Network.Greskell.WebSocket.Request.Standard.OpEval instance GHC.Classes.Eq Network.Greskell.WebSocket.Request.Standard.OpEval instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Standard.OpEval instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Standard.OpEval instance Network.Greskell.WebSocket.Request.Common.Operation Network.Greskell.WebSocket.Request.Standard.OpEval instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Request.Standard.OpAuthentication instance Network.Greskell.WebSocket.Request.Common.Operation Network.Greskell.WebSocket.Request.Standard.OpAuthentication module Network.Greskell.WebSocket.Response -- | ResponseMessage object from Gremlin Server. See -- http://tinkerpop.apache.org/docs/current/dev/provider/. -- -- Type s is the type of the response data. data ResponseMessage s ResponseMessage :: !UUID -> !ResponseStatus -> !ResponseResult s -> ResponseMessage s [requestId] :: ResponseMessage s -> !UUID [status] :: ResponseMessage s -> !ResponseStatus [result] :: ResponseMessage s -> !ResponseResult s -- | "status" field. data ResponseStatus ResponseStatus :: !ResponseCode -> !Text -> !Object -> ResponseStatus [code] :: ResponseStatus -> !ResponseCode [message] :: ResponseStatus -> !Text [attributes] :: ResponseStatus -> !Object -- | "result" field. data ResponseResult s ResponseResult :: !s -> !Object -> ResponseResult s -- | "data" field. [resultData] :: ResponseResult s -> !s [meta] :: ResponseResult s -> !Object -- | Response status code data ResponseCode Success :: ResponseCode NoContent :: ResponseCode PartialContent :: ResponseCode Unauthorized :: ResponseCode Authenticate :: ResponseCode MalformedRequest :: ResponseCode InvalidRequestArguments :: ResponseCode ServerError :: ResponseCode ScriptEvaluationError :: ResponseCode ServerTimeout :: ResponseCode ServerSerializationError :: ResponseCode codeToInt :: ResponseCode -> Int codeFromInt :: Int -> Maybe ResponseCode -- | Returns True if the ResponseCode is a terminating code. isTerminating :: ResponseCode -> Bool -- | Returns True if the ResponseCode is a success. isSuccess :: ResponseCode -> Bool -- | Returns True if the ResponseCode is a client-side -- failure. isClientSideError :: ResponseCode -> Bool -- | Returns True if the ResponseCode is a server-side -- failure. isServerSideError :: ResponseCode -> Bool instance GHC.Show.Show Network.Greskell.WebSocket.Response.ResponseCode instance GHC.Classes.Ord Network.Greskell.WebSocket.Response.ResponseCode instance GHC.Classes.Eq Network.Greskell.WebSocket.Response.ResponseCode instance GHC.Enum.Enum Network.Greskell.WebSocket.Response.ResponseCode instance GHC.Enum.Bounded Network.Greskell.WebSocket.Response.ResponseCode instance GHC.Show.Show Network.Greskell.WebSocket.Response.ResponseStatus instance GHC.Generics.Generic Network.Greskell.WebSocket.Response.ResponseStatus instance GHC.Classes.Eq Network.Greskell.WebSocket.Response.ResponseStatus instance GHC.Show.Show s => GHC.Show.Show (Network.Greskell.WebSocket.Response.ResponseResult s) instance GHC.Generics.Generic (Network.Greskell.WebSocket.Response.ResponseResult s) instance GHC.Classes.Eq s => GHC.Classes.Eq (Network.Greskell.WebSocket.Response.ResponseResult s) instance GHC.Show.Show s => GHC.Show.Show (Network.Greskell.WebSocket.Response.ResponseMessage s) instance GHC.Generics.Generic (Network.Greskell.WebSocket.Response.ResponseMessage s) instance GHC.Classes.Eq s => GHC.Classes.Eq (Network.Greskell.WebSocket.Response.ResponseMessage s) instance Data.Greskell.GraphSON.FromGraphSON s => Data.Aeson.Types.FromJSON.FromJSON (Network.Greskell.WebSocket.Response.ResponseMessage s) instance Data.Greskell.GraphSON.FromGraphSON s => Data.Greskell.GraphSON.FromGraphSON (Network.Greskell.WebSocket.Response.ResponseMessage s) instance GHC.Base.Functor Network.Greskell.WebSocket.Response.ResponseMessage instance Data.Greskell.GraphSON.FromGraphSON s => Data.Aeson.Types.FromJSON.FromJSON (Network.Greskell.WebSocket.Response.ResponseResult s) instance Data.Greskell.GraphSON.FromGraphSON s => Data.Greskell.GraphSON.FromGraphSON (Network.Greskell.WebSocket.Response.ResponseResult s) instance GHC.Base.Functor Network.Greskell.WebSocket.Response.ResponseResult instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Response.ResponseStatus instance Data.Greskell.GraphSON.FromGraphSON Network.Greskell.WebSocket.Response.ResponseStatus instance Data.Aeson.Types.FromJSON.FromJSON Network.Greskell.WebSocket.Response.ResponseCode instance Data.Greskell.GraphSON.FromGraphSON Network.Greskell.WebSocket.Response.ResponseCode instance Data.Aeson.Types.ToJSON.ToJSON Network.Greskell.WebSocket.Response.ResponseCode module Network.Greskell.WebSocket.Codec -- | Encoder of RequestMessage and decoder of -- ResponseMessage, associated with a MIME type. -- -- Type s is the body of Response. data Codec s Codec :: Text -> (RequestMessage -> ByteString) -> (ByteString -> Either String (ResponseMessage s)) -> Codec s -- | MIME type sent to the server [mimeType] :: Codec s -> Text -- | Request encoder [encodeWith] :: Codec s -> RequestMessage -> ByteString -- | Response decoder [decodeWith] :: Codec s -> ByteString -> Either String (ResponseMessage s) -- | Encode a RequestMessage into a "binary" format of Gremlin -- Server. The result includes the message "header" and the "payload". encodeBinaryWith :: Codec s -> RequestMessage -> ByteString -- | Make a request message header. messageHeader :: Text -> ByteString -- | Decode a message in the "binary" format. This is mainly for testing -- purposes. decodeBinary :: ByteString -> Either String (Text, ByteString) instance GHC.Base.Functor Network.Greskell.WebSocket.Codec.Codec module Network.Greskell.WebSocket.Codec.JSON -- | Simple "application/json" codec. -- -- The encoder uses GraphSON v1 format. The decoder supports all GraphSON -- v1, v2 and v3. jsonCodec :: FromGraphSON s => Codec s module Network.Greskell.WebSocket.Connection.Settings -- | Settings for making connection to Gremlin Server. -- -- You can get the default Settings by defSettings -- function, and customize its fields by accessor functions. -- -- Type s is the body of Response. data Settings s defSettings :: Codec s -> Settings s -- | defSettings with jsonCodec. defJSONSettings :: FromGraphSON s => Settings s -- | codec for the connection. codec :: Settings s -> Codec s -- | Path of the WebSocket endpoint. Default: "/gremlin" endpointPath :: Settings s -> String -- | An exception handler for GeneralException. This exception is -- not fatal, so the connection survives after this handler is called. -- You don't have to re-throw the exception. Default: print the exception -- to stderr. onGeneralException :: Settings s -> GeneralException -> IO () -- | Time out (in seconds) for responses. It is the maximum time for which -- the connection waits for a response to complete after it sends a -- request. If the response consists of more than one ResponseMessages, -- the timeout applies to the last of the ResponseMessages. Default: 60 responseTimeout :: Settings s -> Int -- | Maximum concurrent requests the connection can make to the server. If -- the client tries to make more concurrent requests than this value, -- later requests are queued in the connection or the client may be -- blocked. Default: 4 concurrency :: Settings s -> Int -- | Size of the internal queue of requests. Usually you don't need to -- customize the field. See also concurrency. Default: 8. requestQueueSize :: Settings s -> Int module Network.Greskell.WebSocket.Connection -- | Make a Connection to a Gremlin Server. -- -- If it fails to connect to the specified server, it throws an -- exception. connect :: Settings s -> Host -> Port -> IO (Connection s) -- | 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. close :: Connection s -> IO () -- | A WebSocket connection to a Gremlin Server. -- -- Type s is the body of Response, as in ResponseMessage. data Connection s -- | Host name or an IP address. type Host = String -- | TCP port number. type Port = Int -- | 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 :: Operation o => Connection s -> o -> IO (ResponseHandle s) -- | Like sendRequest, but you can pass a RequestMessage -- directly to this function. sendRequest' :: Connection s -> RequestMessage -> IO (ResponseHandle s) -- | 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. data ResponseHandle s -- | 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. nextResponse :: ResponseHandle s -> IO (Maybe (ResponseMessage s)) -- | STM version of nextResponse. nextResponseSTM :: ResponseHandle s -> STM (Maybe (ResponseMessage s)) -- | Get all remaining ResponseMessages from ResponseHandle. slurpResponses :: ResponseHandle s -> IO (Vector (ResponseMessage s)) -- | Similar to slurpResponses, but this function discards the -- responses. drainResponses :: ResponseHandle s -> IO () -- | Exception general to a Connection. It's not related to specific -- requests. data GeneralException -- | Server sends a ResponseMessage with unknown requestId, which is -- kept in this exception. UnexpectedRequestId :: UUID -> GeneralException -- | The Connection fails to parse a data from the server. The error -- message is kept in this exception. ResponseParseFailure :: String -> GeneralException -- | An exception related to a specific request. data RequestException -- | The connection is already closed before it sends the request. AlreadyClosed :: RequestException -- | The server closed the connection before it sends response for this -- request. ServerClosed :: RequestException -- | The requestId (kept in this object) is already pending in the -- connection. DuplicateRequestId :: UUID -> RequestException -- | The server fails to send ResponseMessages within -- responseTimeout. ResponseTimeout :: RequestException module Network.Greskell.WebSocket.Client.Options -- | Configuration options to create a client for Gremlin Server. -- -- You can get the default Options by defOptions function, -- and customize its fields by accessor functions. data Options defOptions :: Options -- | Settings for the underlying Connection. Default: -- defJSONSettings. connectionSettings :: Options -> Settings GValue -- | "batchSize" field for "eval" operation. Default: Nothing. batchSize :: Options -> Maybe Int -- | "language" field for "eval" operation. Default: Nothing. language :: Options -> Maybe Text -- | "aliases" field for "eval" operation. Default: Nothing. aliases :: Options -> Maybe (HashMap Text Text) -- | "scriptEvaluationTimeout" field for "eval" operation. Default: -- Nothing. scriptEvaluationTimeout :: Options -> Maybe Int module Network.Greskell.WebSocket.Client -- | Create a Client to a Gremlin Server, with the default -- Options. connect :: Host -> Port -> IO Client -- | Create a Client to a Gremlin Server. connectWith :: Options -> Host -> Port -> IO Client -- | Close the connection to the server and release other resources of the -- Client. close :: Client -> IO () -- | A client that establishes a connection to the Gremlin Server. You can -- send Gremlin expression for evaluation by submit function. data Client -- | Host name or an IP address. type Host = String -- | TCP port number. type Port = Int -- | Submit a Gremlin script to the server. You can get its results by -- ResultHandle. The result type v is determined by the -- script type g. -- -- Usually this function does not throw any exception. Exceptions about -- sending requests are reported when you operate on ResultHandle. submit :: (ToGreskell g, r ~ GreskellReturn g, AsIterator r, v ~ IteratorItem r, FromGraphSON v) => Client -> g -> Maybe Object -> IO (ResultHandle v) -- | Submit a pair of Gremlin script and variable binding. It's just a -- simple wrapper around submit. submitPair :: (ToGreskell g, r ~ GreskellReturn g, AsIterator r, v ~ IteratorItem r, FromGraphSON v) => Client -> (g, Object) -> IO (ResultHandle v) -- | Less type-safe version of submit. submitRaw :: Client -> Text -> Maybe Object -> IO (ResultHandle GValue) -- | A handle to receive the result of evaluation of a Gremlin script from -- the server. data ResultHandle v -- | Get the next value from the ResultHandle. If you have got all -- values, it returns Nothing. This function may block for a new -- response to come. -- -- On error, it may throw all sorts of exceptions including -- SubmitException and RequestException. For example, if -- the submitted Gremlin script throws an exception, nextResult -- throws ResponseError with ResponseCode of -- ScriptEvaluationError. nextResult :: ResultHandle v -> IO (Maybe v) -- | STM version of nextResult. nextResultSTM :: ResultHandle v -> STM (Maybe v) -- | Get all remaining results from ResultHandle. slurpResults :: ResultHandle v -> IO (Vector v) -- | Similar to slurpResults, but this function discards the -- results. Useful to execute a script whose side-effect is the only -- thing you care. drainResults :: ResultHandle v -> IO () -- | Exception about submit operation and getting its result. data SubmitException -- | The server returns a ResponseMessage with error -- ResponseCode. ResponseError :: ResponseMessage GValue -> SubmitException -- | The client fails to parse the "data" field of the -- ResponseMessage. The error message is kept in the String -- field. ParseError :: ResponseMessage GValue -> String -> SubmitException module Network.Greskell.WebSocket