-
Notifications
You must be signed in to change notification settings - Fork 6
/
Broker.hs
27 lines (23 loc) · 842 Bytes
/
Broker.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Vaultaire.Broker
(
startProxy,
) where
import System.Log.Logger
import System.ZMQ4.Monadic
-- | Start a ZMQ proxy, capture is always a Pub socket.
--
-- This should never return except in the case of catastrophic failure.
startProxy :: (SocketType front_t, SocketType back_t)
=> (front_t, String) -- ^ Frontend, clients
-> (back_t, String) -- ^ Backend, workers
-> String -- ^ Capture address, for debug
-> ZMQ z ()
startProxy (front_type, front_addr) (back_type, back_addr) cap_addr = do
front_s <- socket front_type
back_s <- socket back_type
cap_s <- socket Pub
bind front_s front_addr
bind back_s back_addr
bind cap_s cap_addr
liftIO $ infoM "Broker.startProxy" ("Broker started on " ++ front_addr)
proxy front_s back_s (Just cap_s)