refactor: Decouple RemoteQueryManager from IManagedSubscriber, IPubTableBroker impl

This commit is contained in:
John Colvin committed 2024-10-30 19:30:30 +00:00
1 parent 0215b7990e
commit 352cb97818
3 files changed
+16 -5

No files matched your search

@@ -4,6 +4,8 @@ using System.Collections.Generic;
using Bts.DataStreamExpressions;
using BCG.Utilities.General;
using bts;
using Bts.PubSub;
using Bts.DataStreamCore;
namespace BCG {
// listens to the requests posted on "cloud_streams" request table, and
@@ -40,13 +42,15 @@ namespace BCG {
private IDictionary<string, StreamPubUnit>
_stream_pub_map = new Dictionary<string, StreamPubUnit>();
private ViewStream _stream = new TableStream("cloud_streams");
private PubTableBroker _broker = new PubTableBroker();
private ManagedSubscriber _sub = ManagedSubscriber.instance;
readonly IPubTableBroker _broker;
readonly IManagedSubscriber _sub;
public RemoteQueryManager() {
public RemoteQueryManager(IManagedSubscriber managedSubscriber, IPubTableBroker pubTableBroker) {
_sub = managedSubscriber;
_broker = pubTableBroker;
_stream.onChange += _on_str;
_sub.subscribe("RemoteRequest", (string tag, byte[] data) => {
_sub.Subscribe("RemoteRequest", (string tag, byte[] data) => {
RemoteRequest req = RemoteRequest.construct_from_bytes(data);
_spawn_remote_stream(req.published_table_name, req.stream_expression, false);
});
@@ -0,0 +1,7 @@
namespace Bts.PubSub;
using System;
public interface IManagedSubscriber {
void Subscribe(string tag, Action<string, byte[]> onData);
}
@@ -17,7 +17,7 @@ namespace BCG {
/// Provides a callback based interface to the SubscriptionCore (this class is mainly here to allow backward compatibility
/// with PubSub, as some clients are still using ManagedSubcribers)
/// </summary>
public class ManagedSubscriber : IWorker, IDisposable {
public class ManagedSubscriber : IManagedSubscriber, IWorker, IDisposable {
private static ManagedSubscriber? _self;
private ISubscriberCore _subcore;
// private IDictionary myTypedDispatchTable = new Hashtable(),