/// <summary> /// Constructor for the Google Cloud Storage data bus /// </summary> /// <param name="storageClient">Reference to the single instance of Google StorageClient</param> /// <param name="loggerFactory">Reference to the logger factory to create the logger</param> /// <param name="rebusTime">Reference to the rebus time interface for getting the current time</param> /// <param name="options">Options to configure the storage bus</param> public GoogleCloudStorageDataBusStorage(StorageClient storageClient, IRebusLoggerFactory loggerFactory, IRebusTime rebusTime, GoogleCloudStorageDataBusOptions options) { _rebusTime = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime)); _options = options ?? throw new ArgumentNullException(nameof(options)); _storageClient = storageClient ?? throw new ArgumentNullException(nameof(storageClient)); // Auto create the bucket when we start up, if required CloudUtils.CreateBucketIfNotExists(storageClient, loggerFactory, options); // Create our retry policy with Polly with a exponential back off strategy for retries, with jitter and retrying immediately on the first failure _retry = CloudUtils.CreateRetryPolicy(options); }
/// <summary> /// Creates the data bus storage container /// </summary> /// <returns>Data bus storage to use</returns> public IDataBusStorage Create() { var connectionInfo = GoogleCloudStorageConnectionInfoUtil.ConnectionInfo.Value; var storageClient = StorageClient.Create(); // We need a longer delay here as one of the tests will cause throttling var options = new GoogleCloudStorageDataBusOptions(connectionInfo.ProjectId, connectionInfo.BucketName) { MedianFirstRetryDelay = TimeSpan.FromMilliseconds(500) }; return(new GoogleCloudStorageDataBusStorage(storageClient, new ConsoleLoggerFactory(false), _fakeRebusTime, options)); }
public void ConfigureDataBus() { // Use a single instance of the storage client var storageClient = StorageClient.Create(); var activator = new BuiltinHandlerActivator(); Using(activator); Configure.With(activator) .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "api")) .DataBus(d => { var options = new GoogleCloudStorageDataBusOptions("my-project-id", "my-bucket") { DoNotUpdateLastReadTime = true, AutoCreateBucket = false, ObjectKeyPrefix = "my-prefix", ObjectKeySuffix = ".my-suffix", }; d.StoreInGoogleCloudStorage(storageClient, options); }) .Start(); }