All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.cosmos.implementation.changefeed.LeaseManager Maven / Gradle / Ivy

Go to download

This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API

There is a newer version: 4.60.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.implementation.changefeed;

import com.azure.cosmos.implementation.changefeed.exceptions.LeaseLostException;
import reactor.core.publisher.Mono;

/**
 * It defines a way to perform operations with {@link Lease}.
 */
public interface LeaseManager {
    /**
     * Checks whether the lease exists and creates it if it does not exist.
     *
     * @param leaseToken the lease token to work with.
     * @param continuationToken the continuation token if it exists.
     * @return the lease.
     */
    Mono createLeaseIfNotExist(String leaseToken, String continuationToken);

    /**
     * Deletes the lease.
     *
     * @param lease the lease to delete.
     * @return a deferred computation of this call.
     */
    Mono delete(Lease lease);

    /**
     * Acquires ownership of the lease.
     *   It can throw {@link LeaseLostException} if other host acquired concurrently the lease.
     *
     * @param lease the lease to acquire.
     * @return the updated lease.
     */
    Mono acquire(Lease lease);

    /**
     * It releases ownership of the lease.
     *   It can throw {@link LeaseLostException} if other host acquired the lease.
     *
     * @param lease the lease to acquire.
     * @return a deferred computation of this call.
     */
    Mono release(Lease lease);

    /**
     * Renew the lease; leases are periodically renewed to prevent expiration.
     *   It can throw {@link LeaseLostException} if other host acquired the lease.
     *
     * @param lease the lease to renew.
     * @return the updated lease.
     */
    Mono renew(Lease lease);

    /**
     * REPLACE item from the specified lease.
     *   It can throw {@link LeaseLostException} if other host acquired the lease.
     *
     * @param leaseToUpdatePropertiesFrom the new item.
     * @return updated lease.
     */
    Mono updateProperties(Lease leaseToUpdatePropertiesFrom);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy