Esempio n. 1
0
        private async Task InitSockets(EtcdClient client)
        {
            _client        = client;
            _brokerSockets = await BrokerSocketHandler.UpdateBrokerSockets(client, _brokerSockets);

            await BrokerSocketHandler.UpdateBrokerSocketsDictionary(client, _brokerSocketsDict, _brokerSockets);

            client.WatchRange(BrokerSocketHandler.BrokerTablePrefix, async events =>
            {
                _brokerSocketHandlerLock.WaitOne();
                _brokerSockets = await BrokerSocketHandler.BrokerTableChangedHandler(events, _brokerSockets);
                _brokerSocketHandlerLock.Release();
            });
            client.WatchRange(BrokerSocketHandler.TopicTablePrefix, events =>
            {
                _brokerSocketHandlerLock.WaitOne();
                BrokerSocketHandler.TopicTableChangedHandler(events, _brokerSocketsDict, _brokerSockets);
                _brokerSocketHandlerLock.Release();
            });
        }
Esempio n. 2
0
        private async Task ForceUpdateBrokerMapping()
        {
            if (_taken == false)
            {
                try
                {
                    await BrokerSocketHandler.UpdateBrokerSocketsDictionary(_client, _brokerSocketsDict, _brokerSockets);

                    await Task.Delay(1000);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to Force update");
                    Console.WriteLine(e);
                    await Task.Delay(1000);
                }
                finally
                {
                    _taken = false;
                }
            }
        }