//====================================
        // ChannelReaderConsumer
        //====================================

        public void Consume(RawMessage message)
        {
            var incoming = message.AsTextMessage();

            var registerService = RegisterService.From(incoming);

            if (registerService.IsValid)
            {
                var attributeSetName = _serviceNamePrefix + registerService.Name.Value;
                foreach (var address in registerService.Addresses)
                {
                    var fullAddress = address.Full;
                    _attributesClient.Add(attributeSetName, fullAddress, fullAddress);
                }
            }
            else
            {
                var unregisterService = UnregisterService.From(incoming);
                if (unregisterService.IsValid)
                {
                    var attributeSetName = _serviceNamePrefix + unregisterService.Name.Value;
                    _attributesClient.RemoveAll(attributeSetName);
                    _attributesClient.Add(_unregisteredServiceNamePrefix + unregisterService.Name.Value, _unregisteredCount, _unpublishedNotifications);
                }
                else
                {
                    Logger.Warn($"DIRECTORY: RECEIVED UNKNOWN: {incoming}");
                }
            }
        }
Esempio n. 2
0
        public void TestValidity()
        {
            var unregisterService = UnregisterService.As(Name.Of("test-service"));

            Assert.True(unregisterService.IsValid);
            Assert.False(UnregisterService.From("blah").IsValid);
            Assert.True(UnregisterService.From(_textMessage).IsValid);
        }