restricted-workers-0.1.0: Running worker processes under system resource restrictions

Safe HaskellNone

System.Restricted.Worker.Protocol

Description

A simple protocol for sending serializable data over handles

Please note that this is a very simple implementation that works fine for most of that data, however, the size of the data you might send at one go is limited to MAX_WORD32 bytes. We use cereal for serialization.

Synopsis

Documentation

sendData :: Serialize a => Handle -> a -> IO ByteStringSource

Send some serialiazable data over a handle. Returns ByteString representing the encoded data. May throw ProtocolException

getData :: Serialize a => Handle -> IO aSource

Read the data from a handle and deserialize it. May throw ProtocolException

getDataSafe :: Serialize a => Handle -> IO (DecodeResult a)Source

Safe version of getData that doesn't throw ProtocolException

type DecodeResult a = Either String aSource

Result of the deserialization

data ProtocolException Source

An exception type used by Protocol

Constructors

ConversionException String

There has been an error during the conversion step

HandleException IOException

There has been an error while using the handler