/// <summary>
        /// It opens a subscription and starts pulling documents since a last processed document for that subscription.
        /// The connection options determine client and server cooperation rules like document batch sizes or a timeout in a matter of which a client
        /// needs to acknowledge that batch has been processed. The acknowledgment is sent after all documents are processed by subscription's handlers.
        /// There can be only a single client that is connected to a subscription.
        /// </summary>
        /// <returns>Subscription object that allows to add/remove subscription handlers.</returns>
        public SubscriptionWorker <T> GetSubscriptionWorker <T>(SubscriptionWorkerOptions options, string database = null) where T : class
        {
            if (options == null)
            {
                throw new InvalidOperationException("Cannot open a subscription if options are null");
            }

            var subscription = new SubscriptionWorker <T>(options, _store, database);

            subscription.OnDisposed += sender => _subscriptions.TryRemove(sender);
            _subscriptions.Add(subscription);

            return(subscription);
        }
 /// <summary>
 /// It opens a subscription and starts pulling documents since a last processed document for that subscription.
 /// The connection options determine client and server cooperation rules like document batch sizes or a timeout in a matter of which a client
 /// needs to acknowledge that batch has been processed. The acknowledgment is sent after all documents are processed by subscription's handlers.
 /// There can be only a single client that is connected to a subscription.
 /// </summary>
 /// <returns>Subscription object that allows to add/remove subscription handlers.</returns>
 public SubscriptionWorker <dynamic> GetSubscriptionWorker(SubscriptionWorkerOptions options, string database = null)
 {
     return(GetSubscriptionWorker <dynamic>(options, database));
 }