@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
54 lines (53 loc) • 2.01 kB
TypeScript
/**
* @module SharedLock
*/
import type { ITimeSpan } from "../../time-span/contracts/_module-exports.js";
import type { ISharedLock } from "../../shared-lock/contracts/shared-lock.contract.js";
import type { IEventListenable } from "../../event-bus/contracts/_module-exports.js";
import type { SharedLockEventMap } from "../../shared-lock/contracts/shared-lock.events.js";
/**
* The `ISharedLockListenable` contract defines a way for listening {@link ISharedLock | `ISharedLock`} operations.
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Contracts
*/
export type ISharedLockListenable = IEventListenable<SharedLockEventMap>;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Contracts
*/
export type SharedLockProviderCreateSettings = {
limit: number;
/**
* You can also provide a `settings.ttl` value using. If not specified it defaults to null, meaning no TTL is applied.
*/
ttl?: ITimeSpan | null;
/**
* You can provide a custom lock id. If not specified a unique lock id will be generated by default.
*/
lockId?: string;
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Contracts
*/
export type ISharedLockProviderBase = {
/**
* The `create` method is used to create an instance of {@link ISharedLock | `ISharedLock`}.
*
* @param key - can be a string or an `Iterable` of strings.
* If it's an `Iterable`, it will be joined into a single string.
* Think of an `Iterable` as representing a path.
*/
create(key: string, settings: SharedLockProviderCreateSettings): ISharedLock;
};
/**
* The `ISharedLockProvider` contract defines a way for managing locks independent of the underlying technology.
* It commes with more convient methods compared to `ISharedLockAdapter`.
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Contracts
*/
export type ISharedLockProvider = ISharedLockListenable & ISharedLockProviderBase;