/// <summary> /// Subscribes to bucket change notifications (a Minio-only extension) /// </summary> /// <param name="bucketName">Bucket to get notifications from</param> /// <param name="events">Events to listen for</param> /// <param name="prefix">Filter keys starting with this prefix</param> /// <param name="suffix">Filter keys ending with this suffix</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns>An observable of JSON-based notification events</returns> public IObservable <MinioNotificationRaw> ListenBucketNotificationsAsync(string bucketName, IList <EventType> events, string prefix = "", string suffix = "", CancellationToken cancellationToken = default(CancellationToken)) { List <EventType> eventList = new List <EventType>(events); ListenBucketNotificationsArgs args = new ListenBucketNotificationsArgs() .WithBucket(bucketName) .WithEvents(eventList) .WithPrefix(prefix) .WithSuffix(suffix); return(this.ListenBucketNotificationsAsync(args, cancellationToken)); }
/// <summary> /// Subscribes to bucket change notifications (a Minio-only extension) /// </summary> /// <param name="args">ListenBucketNotificationsArgs Arguments Object with information like Bucket name, listen events, prefix filter keys, suffix filter keys</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns>An observable of JSON-based notification events</returns> public IObservable <MinioNotificationRaw> ListenBucketNotificationsAsync(ListenBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken)) { return(Observable.Create <MinioNotificationRaw>( async(obs, ct) => { bool isRunning = true; using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, ct)) { while (isRunning) { args = args.WithNotificationObserver(obs) .WithEnableTrace(this.trace); RestRequest request = await this.CreateRequest(args).ConfigureAwait(false); await this.ExecuteAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false); cts.Token.ThrowIfCancellationRequested(); } } })); }