Skip to content

@codesoul-co/hypha-core / modules/runtime/run-lease-store

Using this module

Use the Run lease store module for persisting and reading data at this boundary. It exports 1 class, 2 functions, 1 interface.

Import from the package entrypoint

ts
import {
  InMemoryRunLeaseStore,
  runLeaseGuard,
  runLeaseScopeKey,
} from '@codesoul-co/hypha-core';

import type {
  InMemoryRunLeaseStoreOptions,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 1 type/interface export as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 2 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
InMemoryRunLeaseStoreclassnew InMemoryRunLeaseStore(options?: InMemoryRunLeaseStoreOptions): InMemoryRunLeaseStoreIn Memory Run Lease Store class with 7 public constructor or member entries; its exact declarations are listed below.
runLeaseGuardfunctionrunLeaseGuard(lease: FencedRunLease): { leaseId: string; ownerId: string; fencingToken: number; }Run Lease Guard function with 1 public call signature; parameters and return types are listed below.
runLeaseScopeKeyfunctionrunLeaseScopeKey(scope: RunLeaseScope): stringRun Lease Scope Key function with 1 public call signature; parameters and return types are listed below.
InMemoryRunLeaseStoreOptionsinterfaceinterface InMemoryRunLeaseStoreOptionsIn Memory Run Lease Store Options interface with 1 public fields or methods.

InMemoryRunLeaseStore

In Memory Run Lease Store class with 7 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class InMemoryRunLeaseStore implements RunLeaseStore {
    constructor(options?: InMemoryRunLeaseStoreOptions);
    acquire(request: RunLeaseAcquireRequest): Promise<FencedRunLease | null>;
    preempt(request: RunLeasePreemptRequest): Promise<FencedRunLease>;
    heartbeat(request: RunLeaseHeartbeatRequest): Promise<FencedRunLease>;
    release(request: RunLeaseReleaseRequest): Promise<void>;
    get(scope: RunLeaseScope, checkedAt?: string): Promise<FencedRunLease | null>;
    assertCurrent(request: RunLeaseAssertionRequest): Promise<FencedRunLease>;
}

Public members

MemberKindSignatureDescription
acquiremethodacquire(request: RunLeaseAcquireRequest): Promise<FencedRunLease | null>Public method; parameters and return type are shown in the signature.
assertCurrentmethodassertCurrent(request: RunLeaseAssertionRequest): Promise<FencedRunLease>Public method; parameters and return type are shown in the signature.
constructorconstructor(options?: InMemoryRunLeaseStoreOptions): InMemoryRunLeaseStoreCreates an instance of this class.
getmethodget(scope: RunLeaseScope, checkedAt?: string): Promise<FencedRunLease | null>Public method; parameters and return type are shown in the signature.
heartbeatmethodheartbeat(request: RunLeaseHeartbeatRequest): Promise<FencedRunLease>Public method; parameters and return type are shown in the signature.
preemptmethodpreempt(request: RunLeasePreemptRequest): Promise<FencedRunLease>Public method; parameters and return type are shown in the signature.
releasemethodrelease(request: RunLeaseReleaseRequest): Promise<void>Public method; parameters and return type are shown in the signature.

runLeaseGuard

Run Lease Guard function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function runLeaseGuard(lease: FencedRunLease): {
    leaseId: string;
    ownerId: string;
    fencingToken: number;
};

Call signature

text
runLeaseGuard(lease: FencedRunLease): { leaseId: string; ownerId: string; fencingToken: number; }

Parameters

ParameterTypeRequiredDescription
leaseFencedRunLeaseYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: { leaseId: string; ownerId: string; fencingToken: number; }
  • Description: The return contract is defined by the type shown above.

runLeaseScopeKey

Run Lease Scope Key function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function runLeaseScopeKey(scope: RunLeaseScope): string;

Call signature

text
runLeaseScopeKey(scope: RunLeaseScope): string

Parameters

ParameterTypeRequiredDescription
scopeRunLeaseScopeYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

InMemoryRunLeaseStoreOptions

In Memory Run Lease Store Options interface with 1 public fields or methods.

Declaration

text
export interface InMemoryRunLeaseStoreOptions {
    now?: () => string;
}

Contract members

MemberKindSignatureDescription
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.