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

PortabilityUNIX
StabilityStable
Maintaineralex.martin@help.com
Safe HaskellNone

HelpEsbClient

Contents

Description

 

Synopsis

Classes

class EsbSend a whereSource

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

Methods

esbSendSource

Arguments

:: Socket

The socket connection.

-> a

The payload.

-> IO ()

Any IO output.

The esbSend method takes a socket and writes somekind 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 whereSource

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

Methods

esbRecieveSource

Arguments

:: Socket

The socket connection.

-> a

The payload.

-> IO ()

Any IO output.

The esbRecieve method takes a socket and reads somekind of payload.

Instances

EsbRecieve Message

The EsbRecieve instance for a Login response.

Raw Exported Functions

getSocketSource

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.

sendSocketDataSource

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.

readSocketDataRawSource

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.

readSocketDataSource

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

esbInitSource

Arguments

:: Text

Group name.

-> [Text]

Subscriptions.

-> String

Host address.

-> Int

Host port.

-> IO Socket

The socket connection.

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

esbListenSource

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

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

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

loggerSource

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