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)); }
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)); }
public void Remove(ContainerInformation containerInfo) { var ctr = HoldingYard.FindByInfo(containerInfo); if (ctr != null) { HoldingYard.Remove(ctr); } }
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)); }
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)); }
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); }
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); }
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); }
public void ExtractContainerInformationFromHeader(string headerKey, ContainerInformation containerInformation) => // When moving to CSharp 9 these can be static lambdas ExtractContainerInformationFromHeader(headerKey, (_, container) => container, containerInformation);
public bool TryExtract(IReadOnlyDictionary <string, string> headers, out ContainerInformation?containerInformation) { containerInformation = new ContainerInformation(SetupFixture.ContainerName, new PartitionKeyPath(SetupFixture.PartitionPathKey)); return(true); }
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);
public Container(BlobContainerClient container, ContainerInformation info) { _container = container; _info = info; }
// 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)); }