Browse Source

gotify trade sink

master
Denis Tereshkin 2 years ago
parent
commit
7b2366d664
  1. 3
      src/Config.hs
  2. 11
      src/Main.hs

3
src/Config.hs

@ -33,7 +33,8 @@ data TransaqConnectorConfig = TransaqConnectorConfig { @@ -33,7 +33,8 @@ data TransaqConnectorConfig = TransaqConnectorConfig {
transaqLogPath :: FilePath,
transaqLogLevel :: Int,
tradesinkDashboard :: T.Text,
mqttUri :: T.Text,
gotifyUri :: T.Text,
gotifyToken :: T.Text,
allTradesSubscriptions :: [SubscriptionConfig],
quotationsSubscriptions :: [SubscriptionConfig],
quotesSubscriptions :: [SubscriptionConfig]

11
src/Main.hs

@ -6,7 +6,7 @@ import ATrade (libatrade_gitrev, @@ -6,7 +6,7 @@ import ATrade (libatrade_gitrev,
import ATrade.Broker.Protocol (NotificationSqnum (NotificationSqnum))
import ATrade.Broker.Server (startBrokerServer,
stopBrokerServer)
import ATrade.Broker.TradeSinks.MQTTTradeSink (withMQTTTradeSink)
import ATrade.Broker.TradeSinks.GotifyTradeSink (withGotifyTradeSink)
import ATrade.Broker.TradeSinks.ZMQTradeSink (withZMQTradeSink)
import ATrade.Logging (Message (..), Severity (Debug, Error, Info, Trace, Warning),
fmtMessage, logWith)
@ -71,9 +71,7 @@ main = do @@ -71,9 +71,7 @@ main = do
defaultServerSecurityParams)
stopQuoteSourceServer $ \_ -> withTickerInfoServer logger ctx (tisEndpoint cfg) $ \tisH -> do
withZMQTradeSink ctx (tradesinkDashboard cfg) logger $ \tsDashboard ->
case parseURI (T.unpack $ mqttUri cfg) of
Just uri -> do
withMQTTTradeSink uri mqttTradeSinkTopic logger $ \tsMqtt -> do
withGotifyTradeSink (T.unpack $ gotifyUri cfg) (T.unpack $ gotifyToken cfg) logger $ \tsGotify -> do
txml <- Connector.start logger cfg qssChannel tisH
bracket (startBrokerServer
[Connector.makeBrokerBackend txml (account cfg)]
@ -81,7 +79,7 @@ main = do @@ -81,7 +79,7 @@ main = do
(brokerEndpoint cfg)
(brokerNotificationsEndpoint cfg)
(NotificationSqnum 1)
[tsDashboard, tsMqtt]
[tsDashboard, tsGotify]
defaultServerSecurityParams
logger) (\x -> do
stopBrokerServer x
@ -89,9 +87,6 @@ main = do @@ -89,9 +87,6 @@ main = do
Connector.stop txml) $ \_ -> do
withHistoryProviderServer ctx (historyProviderEndpoint cfg) txml tisH logger id $ \_ -> do
forever $ threadDelay 1000000
Nothing -> log Warning "main" "Can't parse MQTT URI"
log Info "main" "Shutting down"
where
mqttTradeSinkTopic = "/atrade/trades"

Loading…
Cancel
Save