/// <summary>
        /// Creates the subscription storage container
        /// </summary>
        /// <returns>Data bus storage to use</returns>
        public ISubscriptionStorage Create()
        {
            var connectionInfo = GoogleCloudStorageConnectionInfoUtil.ConnectionInfo.Value;
            var storageClient  = StorageClient.Create();
            var options        = new GoogleCloudStorageSubscriptionOptions(connectionInfo.ProjectId, connectionInfo.BucketName);

            return(new GoogleCloudStorageSubscriptionsStorage(storageClient, new ConsoleLoggerFactory(false), options));
        }
示例#2
0
        /// <summary>
        /// Constructor for the Google Cloud Storage subscription storage
        /// </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="options">Options to configure the subscription storage</param>
        public GoogleCloudStorageSubscriptionsStorage(StorageClient storageClient, IRebusLoggerFactory loggerFactory, GoogleCloudStorageSubscriptionOptions options)
        {
            _storageClient = storageClient ?? throw new ArgumentNullException(nameof(storageClient));
            _options       = options ?? throw new ArgumentNullException(nameof(options));

            // 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);
        }
        public void ConfigureSubscriptions()
        {
            // 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"))
            .Subscriptions(d =>
            {
                var options = new GoogleCloudStorageSubscriptionOptions("my-project-id", "my-bucket")
                {
                    DoNotUpdateLastReadTime = true,
                    AutoCreateBucket        = false,
                    ObjectKeyPrefix         = "my-prefix-folder/",
                };
                d.StoreInGoogleCloudStorage(storageClient, options);
            })
            .Start();
        }