< Summary

Class:Microsoft.Azure.EventHubs.Processor.Lease
Assembly:Microsoft.Azure.EventHubs.Processor
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.Processor\src\Lease.cs
Covered lines:0
Uncovered lines:22
Coverable lines:22
Total lines:88
Line coverage:0% (0 of 22)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-0%100%
.ctor(...)-0%100%
get_Offset()-0%100%
get_SequenceNumber()-0%100%
get_PartitionId()-0%100%
get_Owner()-0%100%
get_Token()-0%100%
get_Epoch()-0%100%
IsExpired()-0%100%
IncrementEpoch()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.Processor\src\Lease.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.EventHubs.Processor
 5{
 6    using System.Threading.Tasks;
 7
 8    /// <summary>
 9    /// Contains partition ownership information.
 10    /// </summary>
 11    public class Lease
 12    {
 13        /// <summary></summary>
 014        protected Lease()
 15        {
 016        }
 17
 18        /// <summary></summary>
 19        /// <param name="partitionId"></param>
 020        protected Lease(string partitionId)
 21        {
 022            this.PartitionId = partitionId;
 023            this.Owner = string.Empty;
 024            this.Token = string.Empty;
 025        }
 26
 27        /// <summary></summary>
 28        /// <param name="source"></param>
 029        protected Lease(Lease source)
 30        {
 031            this.PartitionId = source.PartitionId;
 032            this.Epoch = source.Epoch;
 033            this.Owner = source.Owner;
 034            this.Token = source.Token;
 035        }
 36
 37        /// <summary>
 38        /// Gets or sets the current value for the offset in the stream.
 39        /// </summary>
 040        public string Offset { get; set; }
 41
 42        /// <summary>
 43        /// Gets or sets the last checkpointed sequence number in the stream.
 44        /// </summary>
 045        public long SequenceNumber { get; set; }
 46
 47        /// <summary>
 48        /// Gets the ID of the partition to which this lease belongs.
 49        /// </summary>
 050        public string PartitionId { get; set; }
 51
 52        /// <summary>
 53        /// Gets or sets the host owner for the partition.
 54        /// </summary>
 055        public string Owner { get; set; }
 56
 57        /// <summary>
 58        /// Gets or sets the lease token that manages concurrency between hosts. You can use this token to guarantee sin
 59        /// </summary>
 060        public string Token { get; set; }
 61
 62        /// <summary>
 63        /// Gets or sets the epoch year of the lease, which is a value you can use to determine the most recent owner of
 64        /// </summary>
 065        public long Epoch { get; set; }
 66
 67        /// <summary>
 68        /// Determines whether the lease is expired.
 69        /// </summary>
 70        /// <returns></returns>
 71        public virtual Task<bool> IsExpired()
 72        {
 73            // By default lease never expires.
 74            // Deriving class will implement the lease expiry logic.
 075            return Task.FromResult(false);
 76        }
 77
 78    /// <summary>
 79    /// Increments the stored epoch in the checkpoint.
 80    /// </summary>
 81    /// <returns></returns>
 82        public long IncrementEpoch()
 83        {
 084            this.Epoch++;
 085            return this.Epoch;
 86        }
 87    }
 88}