public async Task <string> GetBlobUrl(string fileName)
        {
            await _storage.CreateContainerIfNotExistsAsync(ContainerName);

            var hasBlob = await _storage.HasBlobAsync(ContainerName, fileName);

            return(hasBlob ?
                   _storage.GetBlobUrl(ContainerName, fileName) : null);
        }
        public async Task <byte[]> GetAsync(string fileName)
        {
            await _storage.CreateContainerIfNotExistsAsync(ContainerName);

            using (var stream = await _storage.GetAsync(ContainerName, fileName))
            {
                byte[] buffer = new byte[stream.Length];
                await stream.ReadAsync(buffer, 0, (int)stream.Length);

                return(buffer);
            }
        }
        protected BlobRepository(IBlobStorage storage, string container)
        {
            _container = container;
            _storage   = storage;

            storage.CreateContainerIfNotExistsAsync(_container).GetAwaiter().GetResult();
        }
示例#4
0
        public async Task SaveContentAsync(string messageId, string content)
        {
            await _blobStorage.CreateContainerIfNotExistsAsync(ContainerName);

            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            await _blobStorage.SaveBlobAsync(ContainerName, messageId, Encoding.UTF8.GetBytes(content));
        }
        public void Start()
        {
            var settings = new RabbitMqSubscriptionSettings
            {
                ConnectionString       = _config.QuoteSubscriber.ConnectionString,
                ExchangeName           = _config.QuoteSubscriber.Exchange,
                QueueName              = $"{_config.QuoteSubscriber.Exchange}.{_config.QuoteSubscriber.QueueSuffix}",
                DeadLetterExchangeName = null,
                IsDurable              = false
            };

            _subscriber = new RabbitMqSubscriber <Quote>(LegacyLykkeLogFactoryToConsole.Instance, settings,
                                                         new ResilientErrorHandlingStrategy(LegacyLykkeLogFactoryToConsole.Instance, settings,
                                                                                            TimeSpan.FromSeconds(10)))
                          .SetMessageDeserializer(new JsonMessageDeserializer <Quote>())
                          .SetMessageReadStrategy(new MessageReadQueueStrategy())
                          .Subscribe(ProcessMessageAsync)
                          .CreateDefaultBinding()
                          .Start();

            _blobStorage.CreateContainerIfNotExistsAsync(_container).GetAwaiter().GetResult();
        }
示例#6
0
 public async Task <bool> CreateContainerIfNotExistsAsync(string container)
 => await WrapAsync(async() => await _impl.CreateContainerIfNotExistsAsync(container), container);
示例#7
0
 public async Task <bool> CreateContainerIfNotExistsAsync(string container)
 => await _retryService.RetryAsync(async() => await _impl.CreateContainerIfNotExistsAsync(container), _onModificationsRetryCount);