public AmazonS3SubscriptionsStorage(AWSCredentials credentials, AmazonS3Config amazonS3Config, AmazonS3DataBusOptions options, IRebusLoggerFactory rebusLoggerFactory)
     : this(rebusLoggerFactory)
 {
     _awsCredentials = credentials ?? throw new ArgumentNullException(nameof(credentials));
     _awsConfig      = amazonS3Config ?? throw new ArgumentNullException(nameof(amazonS3Config));
     _options        = options ?? throw new ArgumentNullException(nameof(options));
 }
Ejemplo n.º 2
0
        public AmazonS3DataBusStorage(
            AmazonS3Config amazonS3Config,
            AmazonS3DataBusOptions options,
            TransferUtilityConfig transferUtilityConfig,
            IRebusLoggerFactory rebusLoggerFactory,
            IRebusTime rebusTime)
        {
            _amazonS3Config        = amazonS3Config ?? throw new ArgumentNullException(nameof(amazonS3Config));
            _transferUtilityConfig = transferUtilityConfig ?? throw new ArgumentNullException(nameof(transferUtilityConfig));
            _rebusTime             = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime));
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _log     = rebusLoggerFactory?.GetLogger <AmazonS3DataBusStorage>() ?? throw new ArgumentNullException(nameof(rebusLoggerFactory));
            _metadataCollectionFactory = new S3MetadataCollectionFactory(options);

            if (options.AutoCreateBucket)
            {
                EnsureBucketExistsAsync().GetAwaiter().GetResult();
            }
        }
        public S3MetadataCollectionFactory(AmazonS3DataBusOptions options)
        {
            _delimiter = options.MetadataDelimiter;

            var knownKeys = new HashSet <string> {
                MetadataKeys.ContentEncoding,
                MetadataKeys.Length,
                MetadataKeys.ReadTime,
                MetadataKeys.SaveTime
            };

            if (options.KnownMetadataKeys != null)
            {
                foreach (var key in options.KnownMetadataKeys)
                {
                    knownKeys.Add(key);
                }
            }

            _knownKeyEncoder = new KnownKeyEncoder(knownKeys);
        }
Ejemplo n.º 4
0
        public async Task Metadata_Key_May_Contain_Delimiter()
        {
            // Setup
            var          defaultDelimiter = new AmazonS3DataBusOptions("bucket").MetadataDelimiter;
            const string key      = "SomeKey";
            var          metadata = new Dictionary <string, string>
            {
                [key] = $"Legal{defaultDelimiter}Value"
            };

            // Test
            await using (var source = new MemoryStream(Array.Empty <byte>()))
            {
                await _storage.Save(KnownId, source, metadata);
            }

            // Verify
            var readMetadata = await _storage.ReadMetadata(KnownId);

            Assert.That(readMetadata[key], Is.EqualTo(metadata[key]));
        }
        public async Task ThisIsHowItLooks()
        {
            var activator = new BuiltinHandlerActivator();

            Using(activator);

            Configure.With(activator)
            .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "api-tjek"))
            .DataBus(d =>
            {
                var options = new AmazonS3DataBusOptions("my-bucket")
                {
                    DoNotUpdateLastReadTime = true
                };

                var credentials = new BasicAWSCredentials("access-key", "secret-key");
                var config      = new AmazonS3Config();

                d.StoreInAmazonS3(credentials, config, options);
            })
            .Start();
        }
Ejemplo n.º 6
0
        public void Throws_When_Trying_To_Use_Metadata_Delimiter_In_Key_Part()
        {
            // Setup
            var defaultDelimiter = new AmazonS3DataBusOptions("bucket").MetadataDelimiter;
            var illegalMetadata  = new Dictionary <string, string>
            {
                [$"Illegal{defaultDelimiter}Key"] = "Any Value"
            };

            // Test
            var exception = Assert.Throws <AggregateException>(() =>
            {
                using var source = new MemoryStream(Array.Empty <byte>());

                _storage.Save(KnownId, source, illegalMetadata).Wait();
            });

            // Verify
            var rebusException = exception.GetBaseException();

            Assert.That(rebusException, Is.TypeOf <RebusApplicationException>());
            Assert.That(rebusException.InnerException, Is.TypeOf <ArgumentException>());
        }
Ejemplo n.º 7
0
 public ObjectIdentity(string id, AmazonS3DataBusOptions options)
 {
     Id  = id;
     Key = CreateObjectKey(id, options.ObjectKeyPrefix, options.ObjectKeySuffix);
 }
 public AmazonS3SubscriptionsStorage(Func <IAmazonS3> amazonS3Factory, AmazonS3DataBusOptions options, IRebusLoggerFactory rebusLoggerFactory)
     : this(rebusLoggerFactory)
 {
     _options         = options ?? throw new ArgumentNullException(nameof(options));
     _amazonS3Factory = amazonS3Factory;
 }