public IReadOnlyList <CloudQueue> Parse(StorageQueueClusterConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("Storage queue cluster config cannot be null");
            }

            if (config.StorageAccounts == null || config.StorageAccounts.Count == 0)
            {
                throw new InvalidOperationException("No storage account specified in config");
            }

            var allCloudQueues = config.StorageAccounts.SelectMany(storageAccount =>
            {
                var account = cloudStorageAccountParser.Parse(storageAccount.ConnectionString);
                OptimizeServicePoint(account.QueueEndpoint);

                var queueClient = account.CreateCloudQueueClient();

                var cloudQueues = storageAccount.Queues
                                  .Select(queue => queueClient.GetQueueReference(queue.Name))
                                  .ToList();
                return(cloudQueues);
            }).ToList();

            return(allCloudQueues);
        }
예제 #2
0
        public IntegrationTests()
        {
            var queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();

            primary   = queueClient.GetQueueReference(PRIMARY_QUEUE);
            secondary = queueClient.GetQueueReference(SECONDARY_QUEUE);

            primary.CreateIfNotExistsAsync();
            secondary.CreateIfNotExistsAsync();

            var clusterConfig = new StorageQueueClusterConfig()
            {
                StorageAccounts = new List <StorageAccountConfig>()
                {
                    new StorageAccountConfig()
                    {
                        ConnectionString = "UseDevelopmentStorage=true",
                        Queues           = new List <QueueConfig>()
                        {
                            new QueueConfig {
                                Name = PRIMARY_QUEUE
                            },
                            new QueueConfig {
                                Name = SECONDARY_QUEUE
                            }
                        }
                    }
                }
            };

            cluster = new StorageQueueClusterBuilder(clusterConfig)
                      .Build();
        }
예제 #3
0
        public void Should_throw_InvalidOperationException_when_there_is_no_storage_account_in_config()
        {
            config = new StorageQueueClusterConfig();

            Assert.Throws <InvalidOperationException>(() => builder.Build());


            config = new StorageQueueClusterConfig()
            {
                StorageAccounts = new List <StorageAccountConfig>()
            };

            Assert.Throws <InvalidOperationException>(() => builder.Build());
        }
예제 #4
0
 internal StorageQueueClusterBuilder(StorageQueueClusterConfig config, IStorageQeueueClusterConfigParser cloudQueueParser)
 {
     this.config           = config ?? throw new ArgumentNullException(nameof(config));
     this.cloudQueueParser = cloudQueueParser ?? throw new ArgumentNullException(nameof(cloudQueueParser));
 }
예제 #5
0
 public StorageQueueClusterBuilder(StorageQueueClusterConfig config)
     : this(config, new StorageQeueueClusterConfigParser(new CloudStorageAccountParser()))
 {
 }