public static async Task <NamespaceBundleConfigurations> Run(IManageNamespaceManagerLifeCycle manageNamespaceManagerLifeCycle, NamespaceConfigurations namespaceConfigurations, string bundlePrefix)
        {
            var namespaceBundleConfigurations = new NamespaceBundleConfigurations();

            foreach (var namespaceConfiguration in namespaceConfigurations)
            {
                var namespaceManager = manageNamespaceManagerLifeCycle.Get(namespaceConfiguration.Alias);
                var namespaceManagerThatCanQueryAndFilterTopics = namespaceManager as NamespaceManagerAdapter;

                // if user has provided an implementation of INamespaceManager, skip the checks all together
                if (namespaceManagerThatCanQueryAndFilterTopics == null)
                {
                    break;
                }

                var numberOfTopics = 1;
                if (await namespaceManagerThatCanQueryAndFilterTopics.CanManageEntities().ConfigureAwait(false))
                {
                    var filter      = $"startswith(path, '{bundlePrefix}') eq true";
                    var foundTopics = await namespaceManagerThatCanQueryAndFilterTopics.GetTopics(filter).ConfigureAwait(false);

                    numberOfTopics = foundTopics.Count();
                }
                namespaceBundleConfigurations.Add(namespaceConfiguration.Alias, numberOfTopics);
            }

            return(namespaceBundleConfigurations);
        }
 public TopologyCreator(ITransportPartsContainer container, IManageNamespaceManagerLifeCycle namespaces)
 {
     this.container  = container;
     this.namespaces = namespaces;
     hasManageRights = new AsyncLazy <bool>(async() =>
     {
         var namespacesWithoutManageRights = await ManageRightsCheck.Run(namespaces, container.Resolve <ReadOnlySettings>())
                                             .ConfigureAwait(false);
         namespacesWithoutManageRightsJoined = string.Join(", ", namespacesWithoutManageRights.Select(alias => $"`{alias}`"));
         return(namespacesWithoutManageRights.Count == 0);
     });
 }
Пример #3
0
        public MessagingFactoryCreator(IManageNamespaceManagerLifeCycle namespaceManagers, ReadOnlySettings settings)
        {
            this.namespaceManagers = namespaceManagers;
            var transportType      = settings.Get <TransportType>(WellKnownConfigurationKeys.Connectivity.TransportType);
            var batchFlushInterval = settings.Get <TimeSpan>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.BatchFlushInterval);

            if (settings.HasExplicitValue(WellKnownConfigurationKeys.Connectivity.MessagingFactories.RetryPolicy))
            {
                retryPolicy = settings.Get <RetryPolicy>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.RetryPolicy);
            }

            if (settings.HasExplicitValue(WellKnownConfigurationKeys.Connectivity.MessagingFactories.MessagingFactorySettingsFactory))
            {
                settingsFactory = settings.Get <Func <string, MessagingFactorySettings> >(WellKnownConfigurationKeys.Connectivity.MessagingFactories.MessagingFactorySettingsFactory);
            }
            else
            {
                settingsFactory = namespaceName =>
                {
                    var factorySettings = new MessagingFactorySettings
                    {
                        TransportType = transportType
                    };

                    switch (transportType)
                    {
                    case TransportType.NetMessaging:
                        factorySettings.NetMessagingTransportSettings = new NetMessagingTransportSettings
                        {
                            BatchFlushInterval = batchFlushInterval
                        };
                        break;

                    case TransportType.Amqp:
                        factorySettings.AmqpTransportSettings = new AmqpTransportSettings
                        {
                            BatchFlushInterval = batchFlushInterval
                        };
                        break;
                    }

                    return(factorySettings);
                };
            }
        }
Пример #4
0
        public static async Task <List <string> > Run(IManageNamespaceManagerLifeCycle manageNamespaceManagerLifeCycle, ReadOnlySettings settings)
        {
            var namespacesWithoutManageRights = new List <string>();

            var namespaces = settings.Get <NamespaceConfigurations>(WellKnownConfigurationKeys.Topology.Addressing.Namespaces);

            foreach (var @namespace in namespaces)
            {
                var namespaceManager  = manageNamespaceManagerLifeCycle.Get(@namespace.Alias);
                var canManageEntities = await namespaceManager.CanManageEntities().ConfigureAwait(false);

                if (!canManageEntities)
                {
                    namespacesWithoutManageRights.Add(@namespace.Alias);
                }
            }

            return(namespacesWithoutManageRights);
        }