Files
spark/src/DataStreamSuite/SharedStreams/Services/SharedStreamsServices.cs
T

35 lines
1.6 KiB
C#

namespace Bts.SharedStreams.Services;
using Bts.DataStreamCore;
using Bts.SharedStreams.StreamFactories;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
public static class SharedStreamsServices {
public static IServiceCollection AddMarketDataStreams(this IServiceCollection services) =>
services.addStreamFactory<BookStreamFactory>()
.addStreamFactory<TradeStreamFactory>()
.addStreamFactory<SpreadBookStreamFactory>()
.addStreamFactory<InstrumentStreamFactory>()
.addStreamFactory<SpatialFuturePairsStreamFactory>()
.addStreamFactory<SpatialArbStatsStreamFactory>();
public static IServiceCollection AddHistoricMarketDataStreams(this IServiceCollection services) =>
services.addStreamFactory<HistoricParquetDataLoader>();
public static IServiceCollection AddNaturalLanguageStreams(this IServiceCollection services, IConfigurationSection configurationSection) =>
services.Configure<NaturalLanguageStreamFactoryConfig>(configurationSection)
.addStreamFactory<NaturalLanguageStreamFactory>();
public static IServiceCollection AddParquetReaderStream(this IServiceCollection services) =>
services.addStreamFactory<ParquetReaderStreamFactory>();
public static IServiceCollection AddGroupByApplyStream(this IServiceCollection services) =>
services.addStreamFactory<GroupByApplyStreamFactory>();
static IServiceCollection addStreamFactory<T>(this IServiceCollection services) where T : class, IDataStreamFactory =>
services.AddSingleton<T>()
.AddSingleton<IDataStreamFactory, T>(sp => sp.GetRequiredService<T>());
}