@@ -21,6 +21,7 @@ import Ambar.Emulator.Connector.MicrosoftSQLServer (SQLServerState)
2121import Ambar.Emulator.Connector.MySQL (MySQLState )
2222import Ambar.Emulator.Connector.Postgres (PostgreSQLState )
2323
24+ import qualified Ambar.Emulator.Server as Server
2425import qualified Ambar.Emulator.Projector as Projector
2526import Ambar.Emulator.Projector (Projection (.. ))
2627import qualified Ambar.Transport.File as FileTransport
@@ -37,6 +38,7 @@ import Ambar.Emulator.Config
3738 , DataDestination (.. )
3839 , Destination (.. )
3940 )
41+ import Util.Async (withAsyncThrow )
4042import Util.Delay (every , seconds )
4143import Util.Directory (writeAtomically )
4244import Util.Logger (SimpleLogger , annotate , logInfo , logDebugAction )
@@ -46,12 +48,18 @@ import Util.STM (atomicallyNamed)
4648emulate :: SimpleLogger -> EmulatorConfig -> EnvironmentConfig -> IO ()
4749emulate logger_ config env = do
4850 Queue. withQueue queuePath pcount $ \ queue ->
51+ withServer queue $
4952 concurrently_ (connectAll queue) (projectAll queue)
5053 where
5154 queuePath = c_dataPath config </> " queues"
5255 statePath = c_dataPath config </> " state.json"
5356 pcount = Topic. PartitionCount $ c_partitionsPerTopic config
5457
58+ withServer queue act =
59+ case c_port config of
60+ Nothing -> act
61+ Just port -> withAsyncThrow (Server. run port queue) act
62+
5563 connectAll queue = do
5664 EmulatorState connectorStates <- load
5765 let getState source =
@@ -180,7 +188,7 @@ toConnectorConfig source sstate =
180188 " Incompatible state for source: " <> show (s_id source)
181189
182190topicName :: Id DataSource -> TopicName
183- topicName sid = TopicName $ " t- " <> unId sid
191+ topicName sid = TopicName $ unId sid
184192
185193projectionId :: Id DataDestination -> Id Projection
186- projectionId (Id dst) = Id ( " p- " <> dst)
194+ projectionId (Id dst) = Id dst
0 commit comments