public void Stop(DataStreamRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            _subscription.Dispose();
            _subscription = null;

            _block.Complete();
            _block = null;
        }
        public DiaggregatorHostedService(DataStreamRegistry registry, IEnumerable <IDataStreamLifetime> items)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            _registry = registry;
            _items    = items.ToArray();
        }
        public void Start(DataStreamRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            _block = new BroadcastBlock <IEnumerable <ConfigurationEntry> >(i => i);
            registry.Register("configuration", _block.AsObservable());

            _block.Post(GetValues());

            _subscription = ChangeToken.OnChange(() => _configuration.GetReloadToken(), () =>
            {
                _block.Post(GetValues());
            });
        }