Namely, in DataStreamPublisher and PubSubServer. This is part of a broader paradigm shift towards Dependency Injection and Factory Pattern. https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines * Use interfaces to decouple services: - Decouple ManagedSubscriber from ISubscriberCore impl - Decouple PubTableBroker from IPublisherCore impl - Decouple RemoteQueryManager from IManagedSubscriber, IPubTableBroker impl * Rename Publishers -> PublisherNodes in DataStreamPublisherConfig * Model config profiles after dotnet appsettings - Rename Configurations/<name>.json -> appsettings.<name>.json - Make json fields match corresponding csharp props verbatim * The Dependency Injection framework doesn't support JsonPropertyName attributes. Config class props must match json fields verbatim. * Move reusable startup code into new Bts.Extensions.Hosting proj * Add pubsub and md-publisher services to compose.yaml
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Bts.DataStream.Services;
|
|
using Bts.DataStreamCore.Services;
|
|
using Bts.DataStreamPublisher.Services;
|
|
using Bts.Extensions.Hosting;
|
|
using Bts.PubSub.Services;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Spark.Api.Services;
|
|
using Spark.Core.Services;
|
|
|
|
using System;
|
|
|
|
var host = HostBuilderExtensions.CreateBtsBuilder(args)
|
|
.ConfigureServices(ConfigureServices)
|
|
.Build();
|
|
try {
|
|
Console.Write("Starting DataStreamPublisher");
|
|
host.Run();
|
|
Console.Write("DataStreamPublisher exited gracefully.");
|
|
} catch (Exception ex) {
|
|
Console.Error.Write($"DataStreamPublisher crashed: {ex}");
|
|
return 1;
|
|
}
|
|
return 0;
|
|
|
|
static void ConfigureServices(HostBuilderContext context, IServiceCollection services) {
|
|
var config = context.Configuration;
|
|
services.AddSpark(config.GetSection("Spark"))
|
|
.AddSparkApi(config.GetSection("SparkApi"))
|
|
.AddMasterWorker(config.GetSection("MasterWorker"))
|
|
.AddViewStreamDatabase()
|
|
.AddPubSubClient(config.GetSection("PubSub"))
|
|
.AddPubTableBroker()
|
|
.AddRemoteQueryManager()
|
|
.AddDataStreamPublisher(config.GetSection("DataStreamPublisher"));
|
|
}
|