public override void Init() { //Set up Adapter to manage single connection for all consumers. Adapter = Adapter.Instance; Adapter.Init(); Adapter.Connect(); //For each StrategyConfig Initialise Rules as micro-services and other default micro-services foreach (StrategyConfiguration strategyConfig in AppConfig.StrategyConfigList) { //Generate Strategy ID here and pass to the State and Rules strategyConfig.Config.Add("StategyId", GenerateStrategyId()); //Create the rule services per strategy Rules = (RulesFactory.CreateAndInitRules(strategyConfig)); Rules.ForEach(rule => rule.Run(Adapter)); //Create a State Manager per strategy Services.Add(new StateManager(strategyConfig)); //Create a Report Manager per strategy Services.Add(new ReportManager(strategyConfig)); Services.ForEach(service => service.Init()); Services.ForEach(service => service.Run(Adapter)); } //TO DO: Set up QueueWatchers to autoscale consumers. Autoscale message is a Service Message with a routingkey = QueueName on the AutoScaleX exchange. }
public void Init() { //Set up Adapter to manage single connection for all consumers. Adapter = Adapter.Instance; Adapter.Init(); Adapter.Connect(); //Create a StateManager to manage global state data StateManager StateManager = new StateManager(); //For each StrategyConfig Initialise Rules as micro-services and other default micro-services foreach (StrategyConfiguration strategyConfig in AppConfig.StrategyConfig) { //Generate Strategy ID here and pass to the State and Rules strategyConfig.StrategyId = StateManager.AddStrategyAsync().Result.ToString(); StateManager.SetStrategyId(strategyConfig.StrategyId); StateManager.UpdateStateAsync("Name", strategyConfig.Name); //Create the rule services per strategy Rules = (RulesFactory.CreateAndInitRules(strategyConfig)); Rules.ForEach(rule => rule.Run(Adapter)); //Create a TradeManager per Strategy to manage linked orders TradeManager TradeManager = new TradeManager(strategyConfig, StateManager); TradeManager.Run(Adapter); //Create a Report Manager per strategy Services.Add(new ReportManager(strategyConfig)); Services.ForEach(service => service.Init()); Services.ForEach(service => service.Run(Adapter)); } }