Пример #1
0
        public AntiEntropy(IHarakaDb harakaDb, IMergeProcedure mergeProcedure, IJsonConfigurator jsonConfigurator)
        {
            _harakaDb         = harakaDb;
            _mergeProcedure   = mergeProcedure;
            _jsonConfigurator = jsonConfigurator;

            //Initialize all existing queues on startup
            foreach (var topic in _harakaDb.TryGetObjects <Topic>("Topics"))
            {
                var smartQueue = new SmartQueue(Setup.container.GetInstance <IUdpCommunication>(), Setup.container.GetInstance <IPersistenceLayer>(), Setup.container.GetInstance <IJsonConfigurator>(), topic);
                _queues.Add(smartQueue);
                smartQueue.SubscribersHasBeenUpdated += SmartQueueOnSubscribersHasBeenUpdated;
            }

            //Fetch all pub
            //Merge tentative
        }
Пример #2
0
        public void QueueDeclareMessageReceived(MessageReceivedEventArgs message)
        {
            var topics = _harakaDb.TryGetObjects <Topic>("Topics");
            var topic  = topics.Find(x => x.Name == message.AdministrationMessage.Topic);

            if (topic != null)
            {
                return;
            }

            lock (_harakaDb.GetLock("Topics"))
            {
                topics = _harakaDb.GetObjects <Topic>("Topics");
                topic  = new Topic(message.AdministrationMessage.Topic);
                topics.Add(topic);
                _harakaDb.StoreObject("Topics", topics);
            }

            var smartQueue = new SmartQueue(Setup.container.GetInstance <IUdpCommunication>(), Setup.container.GetInstance <IPersistenceLayer>(), Setup.container.GetInstance <IJsonConfigurator>(), topic);

            smartQueue.SubscribersHasBeenUpdated += SmartQueueOnSubscribersHasBeenUpdated;
            _queues.Add(smartQueue);
        }