Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentServiceLeaseStoreManagerCosmos"/> class.
        /// </summary>
        /// <remarks>
        /// Internal only for testing purposes, otherwise would be private.
        /// </remarks>
        internal DocumentServiceLeaseStoreManagerCosmos(
            DocumentServiceLeaseStoreManagerOptions options,
            ContainerInternal monitoredContainer,
            ContainerInternal leaseContainer,
            RequestOptionsFactory requestOptionsFactory,
            DocumentServiceLeaseUpdater leaseUpdater) // For testing purposes only.
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (options.ContainerNamePrefix == null)
            {
                throw new ArgumentNullException(nameof(options.ContainerNamePrefix));
            }
            if (string.IsNullOrEmpty(options.HostName))
            {
                throw new ArgumentNullException(nameof(options.HostName));
            }
            if (monitoredContainer == null)
            {
                throw new ArgumentNullException(nameof(monitoredContainer));
            }
            if (leaseContainer == null)
            {
                throw new ArgumentNullException(nameof(leaseContainer));
            }
            if (requestOptionsFactory == null)
            {
                throw new ArgumentException(nameof(requestOptionsFactory));
            }
            if (leaseUpdater == null)
            {
                throw new ArgumentException(nameof(leaseUpdater));
            }

            this.leaseStore = new DocumentServiceLeaseStoreCosmos(
                leaseContainer,
                options.ContainerNamePrefix,
                requestOptionsFactory);

            this.leaseManager = new DocumentServiceLeaseManagerCosmos(
                monitoredContainer,
                leaseContainer,
                leaseUpdater,
                options,
                requestOptionsFactory);

            this.leaseCheckpointer = new DocumentServiceLeaseCheckpointerCore(
                leaseUpdater,
                requestOptionsFactory);

            this.leaseContainer = new DocumentServiceLeaseContainerCosmos(
                leaseContainer,
                options);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentServiceLeaseStoreManagerInMemory"/> class.
        /// </summary>
        /// <remarks>
        /// Internal only for testing purposes, otherwise would be private.
        /// </remarks>
        internal DocumentServiceLeaseStoreManagerInMemory(
            DocumentServiceLeaseUpdater leaseUpdater,
            ConcurrentDictionary <string, DocumentServiceLease> container) // For testing purposes only.
        {
            if (leaseUpdater == null)
            {
                throw new ArgumentException(nameof(leaseUpdater));
            }

            this.leaseStore = new DocumentServiceLeaseStoreInMemory();

            this.leaseManager = new DocumentServiceLeaseManagerInMemory(leaseUpdater, container);

            this.leaseCheckpointer = new DocumentServiceLeaseCheckpointerCore(
                leaseUpdater,
                new PartitionedByIdCollectionRequestOptionsFactory());

            this.leaseContainer = new DocumentServiceLeaseContainerInMemory(container);
        }