help-esb-0.1.3: A Haskell client for the Help.com team's ESB.

Copyright(c) Help.com, LLC, 2014
LicenseMIT
Maintaineralex.martin@help.com
StabilityStable
PortabilityUNIX
Safe HaskellNone
LanguageHaskell98

HelpEsbClient

Contents

Description

 

Synopsis

Classes

class EsbSend a where Source

The EsbSend class determines how a message should be sent to the ESB.

Methods

esbSend Source

Arguments

:: Socket

The socket connection.

-> a

The payload.

-> IO ()

Any IO output.

The esbSend method takes a socket and writes some kind of payload.

Instances

EsbSend Data

The EsbSend instance for an Event post request.

EsbSend Data

The EsbSend instance for an Event Group post request.

EsbSend Data

The EsbSend instance for a login request.

class EsbRecieve a where Source

The EsbRecieve class determines how a message from the ESB should be recieved.

Methods

esbRecieve Source

Arguments

:: Socket

The socket connection.

-> a

The payload.

-> IO ()

Any IO output.

The esbRecieve method takes a socket and reads some kind of payload.

Instances

EsbRecieve Message

The EsbRecieve instance for a Login response.

Raw Exported Functions

getSocket Source

Arguments

:: String

Host address.

-> Int

Host port.

-> IO Socket

The socket connection.

The getSocket function takes a host and port and connects to and returns the socket.

sendSocketData Source

Arguments

:: Socket

The socket connection.

-> ByteString

The JSON bytestring payload.

-> IO ()

Any IO output.

The sendSocketData function accepts a socket and bytes, converts the bytes to cleaned up JSON, and writes the JSON to the socket.

readSocketDataRaw Source

Arguments

:: Socket

The socket connection.

-> IO [Char]

Any IO output.

The readSocketDataRaw function accepts a socket and grabs whatever data might be in the latest message.

readSocketData Source

Arguments

:: Socket

The socket connection.

-> IO ByteString

The JSON bytestring payload.

The readSocketData function accepts a socket, reads and cleans up any JSON for parsing, and returns the bytes of JSON.

ESB Functions

esbInit Source

Arguments

:: Text

Group name.

-> [Text]

Subscriptions.

-> Maybe String

Host address or Nothing. Defaults to 127.0.0.1.

-> Maybe Int

Host port or Nothing. Defaults to 8900.

-> IO Socket

The socket connection.

The esbInit function initializes the socket connection and logs into the ESB.

esbListen Source

Arguments

:: Socket

The socket connection.

-> IO ByteString

The JSON bytestring payload.

The esbListen function performs all essential listening logic for any ESB client.

Utility Functions

encode :: ToJSON a => a -> ByteString

Efficiently serialize a JSON value as a lazy ByteString.

decode :: FromJSON a => ByteString -> Maybe a

Efficiently deserialize a JSON value from a lazy ByteString. If this fails due to incomplete or invalid input, Nothing is returned.

The input must consist solely of a JSON document, with no trailing data except for whitespace. This restriction is necessary to ensure that if data is being lazily read from a file handle, the file handle will be closed in a timely fashion once the document has been parsed.

This function parses immediately, but defers conversion. See json for details.

eitherDecode :: FromJSON a => ByteString -> Either String a

Like decode but returns an error message when decoding fails.

logger Source

Arguments

:: String

Messaged to be logged.

-> IO ()

IO output.

The logger function simply logs out in a consistent way. Will be updated to be more robust.

Utility Types

data Socket :: *

module Data.UUID