summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/QueryResponse.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Network/QueryResponse.hs b/src/Network/QueryResponse.hs
index 6fa301c7..dc25faf8 100644
--- a/src/Network/QueryResponse.hs
+++ b/src/Network/QueryResponse.hs
@@ -59,11 +59,11 @@ forkListener client = do
59-- dispatch the response. 59-- dispatch the response.
60sendQuery :: 60sendQuery ::
61 forall err a b tbl x meth tid addr. 61 forall err a b tbl x meth tid addr.
62 Client err meth tid addr x -- ^ A query/response implementation. 62 Client err meth tid addr x -- ^ A query/response implementation.
63 -> MethodSerializer addr x meth a b -- ^ Information for marshalling the query. 63 -> MethodSerializer tid addr x meth a b -- ^ Information for marshalling the query.
64 -> a -- ^ The outbound query. 64 -> a -- ^ The outbound query.
65 -> addr -- ^ Destination address of query. 65 -> addr -- ^ Destination address of query.
66 -> IO (Maybe b) -- ^ The response, or 'Nothing' if it timed out. 66 -> IO (Maybe b) -- ^ The response, or 'Nothing' if it timed out.
67sendQuery (Client net d err pending whoami _) meth q addr = do 67sendQuery (Client net d err pending whoami _) meth q addr = do
68 mvar <- newEmptyMVar 68 mvar <- newEmptyMVar
69 tid <- atomically $ do 69 tid <- atomically $ do
@@ -72,7 +72,7 @@ sendQuery (Client net d err pending whoami _) meth q addr = do
72 writeTVar pending tbl' 72 writeTVar pending tbl'
73 return tid 73 return tid
74 self <- whoami (Just addr) 74 self <- whoami (Just addr)
75 sendMessage net addr (wrapQuery meth self addr q) 75 sendMessage net addr (wrapQuery meth tid self addr q)
76 mres <- timeout (methodTimeout meth) $ takeMVar mvar 76 mres <- timeout (methodTimeout meth) $ takeMVar mvar
77 case mres of 77 case mres of
78 Just x -> return $ Just $ unwrapResponse meth x 78 Just x -> return $ Just $ unwrapResponse meth x
@@ -139,7 +139,7 @@ dispatchQuery (MethodHandler unwrapQ wrapR f) tid self x addr =
139-- | These four parameters are required to implement an ougoing query. A 139-- | These four parameters are required to implement an ougoing query. A
140-- peer-to-peer algorithm will define a 'MethodSerializer' for every 'MethodHandler' that 140-- peer-to-peer algorithm will define a 'MethodSerializer' for every 'MethodHandler' that
141-- might be returned by 'lookupHandler'. 141-- might be returned by 'lookupHandler'.
142data MethodSerializer addr x meth a b = MethodSerializer 142data MethodSerializer tid addr x meth a b = MethodSerializer
143 { -- | Seconds to wait for a response. 143 { -- | Seconds to wait for a response.
144 methodTimeout :: Int 144 methodTimeout :: Int
145 -- | A method identifier used for error reporting. This needn't be the 145 -- | A method identifier used for error reporting. This needn't be the
@@ -149,7 +149,7 @@ data MethodSerializer addr x meth a b = MethodSerializer
149 -- The /addr/ arguments are, respectively, our own origin address and the 149 -- The /addr/ arguments are, respectively, our own origin address and the
150 -- destination of the request. The /ctx/ argument is useful for attaching 150 -- destination of the request. The /ctx/ argument is useful for attaching
151 -- auxillary notations on all outgoing packets. 151 -- auxillary notations on all outgoing packets.
152 , wrapQuery :: addr -> addr -> a -> x 152 , wrapQuery :: tid -> addr -> addr -> a -> x
153 -- | Parse an inbound packet /x/ into a response /b/ for this query. 153 -- | Parse an inbound packet /x/ into a response /b/ for this query.
154 , unwrapResponse :: x -> b 154 , unwrapResponse :: x -> b
155 } 155 }
@@ -211,12 +211,12 @@ onInbound f tr = tr
211data TransactionMethods d tid x = TransactionMethods 211data TransactionMethods d tid x = TransactionMethods
212 { 212 {
213 -- | Before a query is sent, this function stores an 'MVar' to which the 213 -- | Before a query is sent, this function stores an 'MVar' to which the
214 -- response will be written too. The returned _tid_ is a transaction id 214 -- response will be written too. The returned /tid/ is a transaction id
215 -- that can be used to forget the 'MVar' if the remote peer is not 215 -- that can be used to forget the 'MVar' if the remote peer is not
216 -- responding. 216 -- responding.
217 dispatchRegister :: MVar x -> d -> (tid, d) 217 dispatchRegister :: MVar x -> d -> (tid, d)
218 -- | This method is invoked when an incomming packet _x_ indicates it is 218 -- | This method is invoked when an incomming packet /x/ indicates it is
219 -- a response to the transaction with id _tid_. The returned IO action 219 -- a response to the transaction with id /tid/. The returned IO action
220 -- is will write the packet to the correct 'MVar' thus completing the 220 -- is will write the packet to the correct 'MVar' thus completing the
221 -- dispatch. 221 -- dispatch.
222 , dispatchResponse :: tid -> x -> d -> (d, IO ()) 222 , dispatchResponse :: tid -> x -> d -> (d, IO ())
@@ -228,9 +228,9 @@ data TransactionMethods d tid x = TransactionMethods
228-- | The standard lookup table methods for use as input to 'transactionMethods' 228-- | The standard lookup table methods for use as input to 'transactionMethods'
229-- in lieu of directly implementing 'TransactionMethods'. 229-- in lieu of directly implementing 'TransactionMethods'.
230data TableMethods t tid = TableMethods 230data TableMethods t tid = TableMethods
231 { -- | Insert a new _tid_ entry into the transaction table. 231 { -- | Insert a new /tid/ entry into the transaction table.
232 tblInsert :: forall a. tid -> a -> t a -> t a 232 tblInsert :: forall a. tid -> a -> t a -> t a
233 -- | Delete transaction _tid_ from the transaction table. 233 -- | Delete transaction /tid/ from the transaction table.
234 , tblDelete :: forall a. tid -> t a -> t a 234 , tblDelete :: forall a. tid -> t a -> t a
235 -- | Lookup the value associated with transaction /tid/. 235 -- | Lookup the value associated with transaction /tid/.
236 , tblLookup :: forall a. tid -> t a -> Maybe a 236 , tblLookup :: forall a. tid -> t a -> Maybe a