Browse Source

BrokerServer: debug

master
Denis Tereshkin 12 months ago
parent
commit
99b172c601
  1. 2
      src/ATrade/Broker/Backend.hs
  2. 3
      src/ATrade/Broker/Server.hs

2
src/ATrade/Broker/Backend.hs

@ -21,7 +21,7 @@ backendNotificationOrderId (BackendTradeNotification trade) = tradeOrderId trade
data BrokerBackend = BrokerBackend data BrokerBackend = BrokerBackend
{ {
accounts :: [T.Text], accounts :: [T.Text],
setNotificationCallback :: (Maybe (BrokerBackendNotification -> IO ())) -> IO (), setNotificationCallback :: Maybe (BrokerBackendNotification -> IO ()) -> IO (),
submitOrder :: Order -> IO (), submitOrder :: Order -> IO (),
cancelOrder :: OrderId -> IO (), cancelOrder :: OrderId -> IO (),
stop :: IO () stop :: IO ()

3
src/ATrade/Broker/Server.hs

@ -66,7 +66,6 @@ import System.ZMQ4 (Context, Event (In),
setZapDomain, socket) setZapDomain, socket)
import System.ZMQ4.ZAP (zapApplyCertificate) import System.ZMQ4.ZAP (zapApplyCertificate)
newtype OrderIdGenerator = IO OrderId
type PeerId = B.ByteString type PeerId = B.ByteString
data FullOrderId = FullOrderId ClientIdentity OrderId data FullOrderId = FullOrderId ClientIdentity OrderId
@ -276,6 +275,7 @@ brokerServerThread state logger = finally brokerServerThread' cleanup
return ResponseOk return ResponseOk
_ -> return $ ResponseError "Unknown order" _ -> return $ ResponseError "Unknown order"
RequestNotifications sqnum clientIdentity initialSqnum -> do RequestNotifications sqnum clientIdentity initialSqnum -> do
log Debug "Broker.Server" $ "Request: notifications:" <> (T.pack . show) request
maybeNs <- M.lookup clientIdentity . pendingNotifications <$> readIORef state maybeNs <- M.lookup clientIdentity . pendingNotifications <$> readIORef state
case maybeNs of case maybeNs of
Just ns -> do Just ns -> do
@ -284,6 +284,7 @@ brokerServerThread state logger = finally brokerServerThread' cleanup
return $ ResponseNotifications . L.reverse $ filtered return $ ResponseNotifications . L.reverse $ filtered
Nothing -> return $ ResponseNotifications [] Nothing -> return $ ResponseNotifications []
RequestCurrentSqnum sqnum clientIdentity -> do RequestCurrentSqnum sqnum clientIdentity -> do
log Debug "Broker.Server" $ "Request: current sqnum:" <> (T.pack . show) request
sqnumMap <- notificationSqnum <$> readIORef state sqnumMap <- notificationSqnum <$> readIORef state
notifMap <- pendingNotifications <$> readIORef state notifMap <- pendingNotifications <$> readIORef state
case M.lookup clientIdentity notifMap of case M.lookup clientIdentity notifMap of

Loading…
Cancel
Save