git.iko.soy/distributed-process
on master help sign in
Merge pull request #251 from haskell-distributed/wip/uforward
897f5edAlexander Vershilov
src/Control/Distributed/Process.hs+2
@@ -65,6 +65,7 @@ module Control.Distributed.Process
65 , handleMessage_
65 , handleMessage_
66 , handleMessageIf_
66 , handleMessageIf_
67 , forward
67 , forward
68+ , uforward
68 , delegate
69 , delegate
69 , relay
70 , relay
70 , proxy
71 , proxy
@@ -235,6 +236,7 @@ import Control.Distributed.Process.Internal.Primitives
235 , handleMessage_
236 , handleMessage_
236 , handleMessageIf_
237 , handleMessageIf_
237 , forward
238 , forward
239+ , uforward
238 , delegate
240 , delegate
239 , relay
241 , relay
240 , proxy
242 , proxy
src/Control/Distributed/Process/Internal/Primitives.hs+21
@@ -47,6 +47,7 @@ module Control.Distributed.Process.Internal.Primitives
47 , handleMessage_
47 , handleMessage_
48 , handleMessageIf_
48 , handleMessageIf_
49 , forward
49 , forward
50+ , uforward
50 , delegate
51 , delegate
51 , relay
52 , relay
52 , proxy
53 , proxy
@@ -473,6 +474,26 @@ forward msg them = do
473 liftIO $ traceEvent (localEventBus node)
474 liftIO $ traceEvent (localEventBus node)
474 (MxSent them us msg)
475 (MxSent them us msg)
475
476
477+-- | Forward a raw 'Message' to the given 'ProcessId'.
478+--
479+-- Unlike 'forward', this function is insensitive to 'reconnect'. It will
480+-- try to send the message regardless of the history of connection failures
481+-- between the nodes.
482+uforward :: Message -> ProcessId -> Process ()
483+uforward msg them = do
484+ proc <- ask
485+ let node = processNode proc
486+ us = processId proc
487+ nid = localNodeId node
488+ destNode = (processNodeId them) in do
489+ case destNode == nid of
490+ True -> sendCtrlMsg Nothing (LocalSend them msg)
491+ False -> sendCtrlMsg (Just destNode) $ UnreliableSend (processLocalId them)
492+ msg
493+ -- We do not fire the trace event until after the sending is complete;
494+ -- In the remote case, 'sendCtrlMsg' can block in the networking stack.
495+ liftIO $ traceEvent (localEventBus node)
496+ (MxSent them us msg)
476
497
477-- | Wrap a 'Serializable' value in a 'Message'. Note that 'Message's are
498-- | Wrap a 'Serializable' value in a 'Message'. Note that 'Message's are
478-- 'Serializable' - like the datum they contain - but also note, deserialising
499-- 'Serializable' - like the datum they contain - but also note, deserialising