This class is the main coordinator. It schedules work to be done for a particular subscription.
Inheritance: IDisposable
 public WorkContext(ISubscription subscription, MessageBroker broker)
 {
     Subscription = subscription;
     Broker = broker;
 }
 public WorkContext(ISubscription subscription, MessageBroker broker)
 {
     Subscription = subscription;
     Broker       = broker;
 }
        public MessageBus(IStringMinifier stringMinifier,
                          ILoggerFactory loggerFactory,
                          IPerformanceCounterManager performanceCounterManager,
                          IOptions<MessageBusOptions> optionsAccessor)
        {
            if (stringMinifier == null)
            {
                throw new ArgumentNullException("stringMinifier");
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (optionsAccessor == null)
            {
                throw new ArgumentNullException("optionsAccessor");
            }

            var options = optionsAccessor.Value;

            if (options.MessageBufferSize < 0)
            {
                throw new ArgumentOutOfRangeException(Resources.Error_BufferSizeOutOfRange);
            }

            _stringMinifier = stringMinifier;
            _loggerFactory = loggerFactory;
            Counters = performanceCounterManager;
            _logger = _loggerFactory.CreateLogger<MessageBus>();
            _maxTopicsWithNoSubscriptions = options.MaxTopicsWithNoSubscriptions;

            _gcTimer = new Timer(_ => GarbageCollectTopics(), state: null, dueTime: _gcInterval, period: _gcInterval);

            _broker = new MessageBroker(Counters)
            {
                Logger = _logger
            };

            // The default message store size
            _messageStoreSize = (uint)options.MessageBufferSize;

            _topicTtl = options.TopicTTL;
            _createTopic = CreateTopic;
            _addEvent = AddEvent;
            _removeEvent = RemoveEvent;
            _disposeSubscription = o => DisposeSubscription(o);

            Topics = new TopicLookup();
        }