TimeSeries and TimeBucketStreams, Stream offloading etc

This commit is contained in:
Taha committed 2023-10-23 14:18:31 -04:00
1 parent 33030b1212
commit 88bf04e5f1
31 files changed
+1823 -836

No files matched your search

@@ -1,40 +1,84 @@
using System;
using mbts.config;
using bts.utils;
using System.Threading.Tasks;
using Bts.DataStreamExpressions;
using System.Collections.Generic;
using BCG;
bts.utils.BTSNativeMethods.provide_command_line(args, args.Length);
mbts.config.Configuration.initialize();
bts.Log.Gen.info($"Starting DSPublisher");
Console.WriteLine("Starting DSPublisher...");
// static async Task _run() {
// var login = "bts";
// var passwd = String.Empty;
// Console.WriteLine("Starting DSQA... ");
// // Log.notnull(login);
// // Log.notnull(passwd);
// // var service_ctx = bts.api.core.ServiceContext.create();
// await service_ctx.login(login, passwd);
// }
//Task.Run(async () => await _run());
_publish_stream();
void _publish_stream() {
BCG.ViewStream vs = new LiteralStream("x", "420.0");// new BBOStream();
//new BCG.MDStream();
ViewPublisher vpub = new ViewPublisher(String.Empty, new PubTableBroker(), vs);
vs.onChange += on_change;
static void init(string[] args)
{
Console.WriteLine("Hit key to continue");
Console.ReadLine();
Func<string, string, Task> login = async (l, p) =>
{
var login = l;
var passwd = p;
var service_ctx = bts.api.core.ServiceContext.create();
await service_ctx.login(login, passwd);
};
BTSNativeMethods.provide_command_line(args, args.Length);
Configuration.initialize();
Task.Run(async () => await login("bts", String.Empty));
}
while (true) {
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
ViewStreamDatabase.instance.doWork();
init(args);
_publish_streams();
static ViewStream build_stream(string stream_expression)
{
try
{
var exp = DataStreamExpressionsInterpreter.Evaluate(stream_expression);
var rv = exp.getView(new Dictionary<string, StatementExpression>(0));
return rv;
}
catch (Exception ex)
{
bts.Log.assert(false, $"Could not build stream: {stream_expression} ex: {ex}");
return null;
}
}
void on_change(object obj) {
DataPacket dp = obj as DataPacket;
dp.newRows.print_table((col) => { return 10; });
void _publish_streams()
{
PubTableBroker pb_broker = new PubTableBroker();
CloudStreamManager csm = new CloudStreamManager();
// get it from config
Dictionary<string, string> streams_to_publish = new Dictionary<string, string>() {
{"bbo","bbo()"},
{"instruments","instruments()"},
//{"timesales","timesales(10000)"},
{"books","books()"},
// {"seconds_1_10","second(1,10)"},
{"literal_420","literal(\"x\", \"420.0\")"},
// {"bbo_ts","timeSeries(bbo())"}
};
foreach (var kv in streams_to_publish)
{
var name = kv.Key;
var exp = kv.Value;
BCG.ViewStream vs = build_stream(exp);
ViewPublisher vpub = new ViewPublisher(name, pb_broker, vs);
vs.onChange += on_change;
}
while (true)
{
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
ViewStreamDatabase.instance.doWork();
csm.doWork();
}
}
void on_change(object obj)
{
bts.Log.Gen.info($"DSPublisher on_change dp: {obj}");
}