refactor: Add Api Server service modules for Dependency Injection

* Part of a broader paradigm shift towards Dependency Injection and
  Factory Pattern.
* Adds "api-server" service to docker compose
* Replaces MarketDataClient w/ IMarketDataClient in a few streams
* Replaces ViewStreamDatabase w/ IWorkScheduler in a few streams
This commit is contained in:
John Colvin committed 2026-01-04 21:08:12 +00:00
1 parent 997647e917
commit 856cd552eb
82 files changed
+2368 -1079

No files matched your search

@@ -2,14 +2,14 @@ using BCG;
using bts;
using bts.api.core;
using bts.md;
using Bts.DataStreamQueryAnalyzer;
using Bts.PubSub;
using CommandLine;
using mbts.config;
using Spark.Api.Services;
using Spark.Core.Services;
using System;
using System.Threading.Tasks;
@@ -26,8 +26,17 @@ static class Program {
cfg.MergeWithConfigFile();
cfg.MergeWith(DataStreamQueryAnalyzerConfig.Default());
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
await Configuration.InitializeAsync(cfg.Sparkd);
PrimitiveManager.SetMarketDataClient(new MarketDataClient(new(TimeSpan.FromSeconds(0.5))));
var configLoader = new SparkConfigLoader(new SparkConfigLoaderOpts() { ConfigServer = cfg.Sparkd });
var serviceContext = new ServiceContext(configLoader);
var credentials = new SparkApiCredentials() {
User = cfg.User,
Password = cfg.Password
};
var loginService = new SparkdLoginService(serviceContext, credentials, configLoader);
var permissions = new UserDataPermissions(loginService);
var mdClientConfig = new MarketDataClientConfig() { HotPollInterval = TimeSpan.FromSeconds(0.5) };
var mdClient = new MarketDataClient(configLoader, loginService, permissions, mdClientConfig);
PrimitiveManager.SetMarketDataClient(mdClient);
Log.Gen.info("Starting DataStreamQueryAnalyzer");
var mainForm = new MainForm();
if (cfg.StreamFile is not null) {