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
28 lines
679 B
C#
28 lines
679 B
C#
namespace Bts.PubSub.Server;
|
|
|
|
using BCG;
|
|
|
|
using bts;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
class InternalPublisherQueue : IInternalPublisherQueue {
|
|
readonly SyncQueue<PublishMsg> queue = new();
|
|
readonly object lockObj = new();
|
|
|
|
public void Enqueue(PublishMsg message) {
|
|
Log.Gen.diag($"PubsubMessageReactor.internal_publish msg: {message}");
|
|
Log.Gen.debug_assert(!string.IsNullOrEmpty(message.tag));
|
|
lock (lockObj) {
|
|
queue.enqueue(message);
|
|
}
|
|
}
|
|
|
|
public List<PublishMsg> DequeueMultiple(TimeSpan ts, int maxElements) {
|
|
lock (lockObj) {
|
|
return queue.dequeueMultipleElements(ts, maxElements);
|
|
}
|
|
}
|
|
}
|