@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.
47 lines (46 loc) • 1.65 kB
TypeScript
/**
* @module Semaphore
*/
import { type IEventListenable } from "../../event-bus/contracts/_module.js";
import { type ISemaphore } from "../../semaphore/contracts/semaphore.contract.js";
import { type SemaphoreEventMap } from "../../semaphore/contracts/semaphore.events.js";
import { type ITimeSpan } from "../../time-span/contracts/_module.js";
/**
* The `ISemaphoreListenable` contract defines a way for listening {@link ISemaphore | `ISemaphore`} operations.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreListenable = IEventListenable<SemaphoreEventMap>;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type SemaphoreProviderCreateSettings = {
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;
slotId?: string;
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreProviderBase = {
/**
* The `create` method is used to create an instance of {@link ISemaphore | `ISemaphore`}.
*/
create(key: string, settings: SemaphoreProviderCreateSettings): ISemaphore;
};
/**
* The `ISemaphoreProvider` contract defines a way for managing semaphores independent of the underlying technology.
* It commes with more convient methods compared to `ISemaphoreAdapter`.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreProvider = ISemaphoreListenable & ISemaphoreProviderBase;