10Duke Scale C++ SDK
Loading...
Searching...
No Matches
Leases Class Referenceabstract

#include <Leases.h>

Detailed Description

A read-only lease-cache service.

This is a memory-based cache for leases of checked out licenses. The licensing client stores all leases to a cache, which removes the need for the application developer to do bookkeeping for checked out leases.

This read-only interface allows the application developer to check then contents of the cache.

To operate on the leases (release or heartbeat), use the licensing client.

Note that the lease-cache is a local understanding of what is currently checked out. For example, a leases released by a system administrator from another machine would not be synced to the lease cache.

Inheritance diagram for Leases:
tenduke::se::licensing::MutableLeases tenduke::se::licensing::SimpleLeases tenduke::se::licensing::DefaultLeases

Public Member Functions

virtual std::vector<::tenduke::se::licensing::Lease > getAllLeases ()=0
 Returns all leases in the cache.
virtual std::vector<::tenduke::se::licensing::Lease > getLeasesDueForHeartbeat ()=0
 Returns the leases that are due for heartbeat.
virtual std::int64_t getNextHeartbeatDueEpochS ()=0
 Returns the time when the next lease becomes due for heartbeat.
virtual std::vector<::tenduke::se::licensing::Lease > getLeasesForProduct (const std::string &productName)=0
 Returns all leases for given product.
virtual::tenduke::se::licensing::Lease getLease (const std::string &leaseId)=0
 Returns a lease by id.
virtual bool isEmpty ()=0
 Returns true if the cache is empty.
virtual std::size_t size ()=0
 Returns how many leases the cache contains.

Static Public Attributes

static const std::int64_t NO_HEARTBEAT_DUE_EPOCH_S_MAGIC = INT64_MAX
 Magic value returned by getNextHeartbeatDueEpochS() when no lease can be heartbeat.

Member Function Documentation

◆ getAllLeases()

Returns all leases in the cache.

Returns
-

◆ getLease()

virtual::tenduke::se::licensing::Lease tenduke::se::licensing::Leases::getLease ( const std::string & leaseId)
pure virtual

Returns a lease by id.

Parameters
leaseId
Returns
-
Exceptions
std::out_of_rangeIf no such lease in the cache

◆ getLeasesDueForHeartbeat()

Returns the leases that are due for heartbeat.

A lease is due for heartbeat when the current time is within the heartbeat window of the lease: The lease has not expired (see tenduke::se::licensing::Lease::expiresEpochS) and the earliest allowed heartbeat time (see tenduke::se::licensing::Lease::heartbeatNotBeforeEpochS) has been reached. A lease without the earliest allowed heartbeat time is always due.

Note that the licensing client applies a small tolerance for clock-skew when it checks the leases, so the client may accept a lease slightly before this method reports it as due.

Returns
the leases that can be heartbeat right now

◆ getLeasesForProduct()

virtual std::vector<::tenduke::se::licensing::Lease > tenduke::se::licensing::Leases::getLeasesForProduct ( const std::string & productName)
pure virtual

Returns all leases for given product.

Parameters
productName-
Returns
-

◆ getNextHeartbeatDueEpochS()

virtual std::int64_t tenduke::se::licensing::Leases::getNextHeartbeatDueEpochS ( )
pure virtual

Returns the time when the next lease becomes due for heartbeat.

This is the earliest tenduke::se::licensing::Lease::heartbeatNotBeforeEpochS of the leases that have not expired. The value is in the past, if the cache has leases that are due for heartbeat right now. For a lease without the earliest allowed heartbeat time, the current time is used.

Use this to schedule the next heartbeat: Wait until the returned time and then heartbeat the leases.

Returns
the time as epoch seconds, or NO_HEARTBEAT_DUE_EPOCH_S_MAGIC if the cache has no leases that can be heartbeat

◆ isEmpty()

virtual bool tenduke::se::licensing::Leases::isEmpty ( )
pure virtual

Returns true if the cache is empty.

Returns
true if the cache is empty or false if the cache contains leases.

◆ size()

virtual std::size_t tenduke::se::licensing::Leases::size ( )
pure virtual

Returns how many leases the cache contains.

Returns
number of leases in the cache

The documentation for this class was generated from the following files:
  • api/src/licensing/api/Leases.h
  • api/src/licensing/api/Leases.cpp