コード例 #1
0
        public async Task <IBlobContainer> GetContainerAsync(string requestedName, string targetQueue, CancellationToken cancellationToken)
        {
            ContainerInformation info = await _helixApiStorage.NewAsync(new ContainerCreationRequest(30, requestedName, targetQueue), cancellationToken).ConfigureAwait(false);

            var client = new CloudBlobClient(new Uri($"https://{info.StorageAccountName}.blob.core.windows.net/"), new StorageCredentials(info.WriteToken));
            CloudBlobContainer container = client.GetContainerReference(info.ContainerName);

            return(new Container(container, info));
        }
コード例 #2
0
        public async Task <IBlobContainer> GetContainerAsync(string requestedName)
        {
            ContainerInformation info = await _helixApiStorage.NewOperationAsync(new ContainerCreationRequest(desiredName : requestedName, expirationInDays : 30));

            var client = new CloudBlobClient(new Uri($"https://{info.StorageAccountName}.blob.core.windows.net/"), new StorageCredentials(info.WriteToken));
            CloudBlobContainer container = client.GetContainerReference(info.ContainerName);

            return(new Container(container, info));
        }
コード例 #3
0
        public void Remove(ContainerInformation containerInfo)
        {
            var ctr = HoldingYard.FindByInfo(containerInfo);

            if (ctr != null)
            {
                HoldingYard.Remove(ctr);
            }
        }
コード例 #4
0
ファイル: ApiBlobHelper.cs プロジェクト: ViktorHofer/arcade
        public async Task <IBlobContainer> GetContainerAsync(string requestedName, string targetQueue, CancellationToken cancellationToken)
        {
            ContainerInformation info = await _helixApiStorage.NewAsync(new ContainerCreationRequest(30, requestedName, targetQueue), cancellationToken).ConfigureAwait(false);

            Uri containerUri         = new Uri($"https://{info.StorageAccountName}.blob.core.windows.net/{info.ContainerName}");
            AzureSasCredential creds = new AzureSasCredential(info.WriteToken);
            var container            = new BlobContainerClient(containerUri, creds, StorageRetryPolicy.GetBlobClientOptionsRetrySettings());

            return(new Container(container, info));
        }
コード例 #5
0
        public async Task <IBlobContainer> GetContainerAsync(string requestedName)
        {
            ContainerInformation info = await _helixApi.RetryAsync(
                () => _helixApiStorage.NewAsync(
                    new ContainerCreationRequest {
                DesiredName = requestedName, ExpirationInDays = 30
            }),
                ex => { },
                CancellationToken.None);

            var client = new CloudBlobClient(new Uri($"https://{info.StorageAccountName}.blob.core.windows.net/"), new StorageCredentials(info.WriteToken));
            CloudBlobContainer container = client.GetContainerReference(info.ContainerName);

            return(new Container(container, info));
        }
コード例 #6
0
        public void FindByInfo_Retrieves_Container_Using_ID()
        {
            // arrange
            var yard                = new HoldingYard();
            var container           = CreateContainer();
            ContainerInformation ci = container.Information();

            yard.Add(container);

            // act
            var ctr = yard.FindByInfo(ci);

            // assert
            Assert.Equal(container.Id, ctr.Id);
        }
コード例 #7
0
        public async Task Should_set_container_when_container_information_extractor_returns_true()
        {
            var containerInformationExtractor = new ContainerInformationExtractor(
                (IReadOnlyDictionary <string, string> headers, out ContainerInformation? container) =>
            {
                container = new ContainerInformation("containerName", new PartitionKeyPath("/deep/down"));
                return(true);
            });

            var behavior = new TransactionInformationBeforeThePhysicalOutboxBehavior(new CosmosDB.PartitionKeyExtractor(), containerInformationExtractor);

            var context = new TestableTransportReceiveContext();

            await behavior.Invoke(context, _ => Task.CompletedTask);

            Assert.That(context.Extensions.TryGet <ContainerInformation>(out var containerInformation), Is.True);
            Assert.AreEqual(new ContainerInformation("containerName", new PartitionKeyPath("/deep/down")), containerInformation);
        }
コード例 #8
0
 public Container(CloudBlobContainer container, ContainerInformation info)
 {
     _container = container;
     _info      = info;
 }
 public bool TryExtract(object message, IReadOnlyDictionary <string, string> headers, out ContainerInformation?containerInformation)
 {
     containerInformation           = new ContainerInformation(SetupFixture.ContainerName, new PartitionKeyPath(SetupFixture.PartitionPathKey));
     testContext.ExtractorWasCalled = true;
     return(true);
 }
コード例 #10
0
 public void ExtractContainerInformationFromHeader(string headerKey, ContainerInformation containerInformation) =>
 // When moving to CSharp 9 these can be static lambdas
 ExtractContainerInformationFromHeader(headerKey, (_, container) => container, containerInformation);
コード例 #11
0
 public bool TryExtract(IReadOnlyDictionary <string, string> headers, out ContainerInformation?containerInformation)
 {
     containerInformation = new ContainerInformation(SetupFixture.ContainerName, new PartitionKeyPath(SetupFixture.PartitionPathKey));
     return(true);
 }
コード例 #12
0
 public bool TryExtract(IReadOnlyDictionary <string, string> headers,
                        out ContainerInformation?containerInformation)
 {
     containerInformation = new ContainerInformation(headers["HeaderKey"], partitionKeyPath);
     return(true);
 }
 /// <summary>
 /// Adds an extraction rule that provides the same container information for a given message type <typeparamref name="TMessage"/>
 /// </summary>
 /// <param name="containerInformation">The container information to be used for the specified <typeparamref name="TMessage"/>.</param>
 /// <typeparam name="TMessage">The message type to match against.</typeparam>
 /// <remarks>Explicitly added extractors and extraction rules are executed before extractors registered on the container.</remarks>
 public void ExtractContainerInformationFromMessage <TMessage>(ContainerInformation containerInformation) =>
 ContainerInformationExtractor.ExtractContainerInformationFromMessage <TMessage>(containerInformation);
 /// <summary>
 /// Adds an extraction rule that provides the same container information when the given <paramref name="headerKey"/> exists.
 /// </summary>
 /// <param name="headerKey">The header key.</param>
 /// <param name="containerInformation">The container information to be used for the specified <paramref name="headerKey"/>.</param>
 /// <remarks>Explicitly added extractors and extraction rules are executed before extractors registered on the container.</remarks>
 public void ExtractContainerInformationFromHeader(string headerKey, ContainerInformation containerInformation) =>
 ContainerInformationExtractor.ExtractContainerInformationFromHeader(headerKey, containerInformation);
 public void ExtractContainerInformationFromMessage <TMessage>(ContainerInformation containerInformation) =>
 // When moving to CSharp 9 these can be static lambdas
 ExtractContainerInformationFromMessage <TMessage, ContainerInformation>((_, container) => container, containerInformation);
コード例 #16
0
ファイル: ApiBlobHelper.cs プロジェクト: ViktorHofer/arcade
 public Container(BlobContainerClient container, ContainerInformation info)
 {
     _container = container;
     _info      = info;
 }
コード例 #17
0
ファイル: HoldingYard.cs プロジェクト: fankersmit/BlueTrain
 // return null if not found
 // finding does not remove container from yard
 public Container FindByInfo(ContainerInformation containerInfo)
 {
     return(_containers.SingleOrDefault(ctr => ctr.Id == containerInfo.Id));
 }