Acquire the lease on the desired partition for this EventProcessorHost.
Note that it is legal to acquire a lease that is already owned by another host. Lease-stealing is how partitions are redistributed when additional hosts are started.
The existing Azure Storage implementation can experience races between two host instances attempting to acquire or steal the lease at the same time. To avoid situations where two host instances both believe that they own the lease, acquisition can fail without errors by returning false and should do so when there is any doubt -- the worst that can happen is that no host instance owns the lease for a short time. This is qualitatively different from, for example, the underlying store throwing an access exception, which is an error.
Lease info for the desired partition as previously obtained from
getLease()
.
Promisetrue
if acquired successfully; false
otherwise.
Create in the store the lease info for the given partition, if it does not exist. Do nothing if it does exist in the store already.
ids of partitions to create lease info for
Promise
Create the lease store if it doesn't exist. Do nothing if it does exist.
Promiseundefined
; rejects with an Error
.
Delete the lease info for the given partition from the store. If there is no stored lease for the given partition, that is treated as success.
Lease info for the desired partition as previously obtained from
getLease()
.
Promiseundefined
; rejects with an Error
.
Delete lease store.
Promiseundefined
; rejects with an Error
.
Returns lightweight BaseLease for all leases, which includes name of owning host and whether lease is expired. An implementation is free to return CompleteLease or its own class derived from CompleteLease, but it is important that getAllLeases run as fast as possible. If it is faster to obtain only the information required for a BaseLease, we heavily recommend doing that.
Promise<BaseLease[]>
Gets the lease info for the specified partition. Can return undefined
if no lease has been
created in the store for the specified partition.
Partition id to get the lease for.
Promise<Lease | undefined>
Does the lease store exist?
Promisetrue
if it exists, false
if it does not exist.
Give up a lease currently held by this host.
If the lease has been stolen, or expired, releasing it is unnecessary, and will fail if attempted.
Lease info for the desired partition as previously obtained from
getLease()
.
Promiseundefined
; rejects with an Error
.
Renew a lease currently held by this host.
If the lease has been taken by another host instance (either stolen or after expiration) or explicitly released, renewLease must return false. With the Azure Storage-based implementation, it IS possible to renew an expired lease that has not been taken by another host, so your implementation can allow that or not, whichever is convenient. If it does not, renewLease should return false.
lease to be renewed.
Promisetrue
if renewed successfully; false
otherwise.
Update the store with the information in the provided lease.
It is necessary to currently hold a lease in order to update it. If the lease has been stolen, or expired, or released, it cannot be updated. Lease manager implementations should renew the lease before performing the update to avoid lease expiration during the process.
New lease information to be stored.
Promisetrue
if updated successfully; false
otherwise.
Generated using TypeDoc
LeaseManager If you wish to have EventProcessorHost store leases somewhere other than Azure Storage, you can write your own lease manager using this interface.
The Azure Storage managers use the same storage for both lease and checkpoints, so both interfaces are implemented by the same class. You are free to do the same thing if you have a unified store for both types of data.
This interface does not specify initialization methods because we have no way of knowing what information your implementation will require.