Skip to content

Rulvar API reference


Rulvar API reference / @rulvar/core / MemoryAdmissionScheduler

Class: MemoryAdmissionScheduler

Defined in: packages/core/src/admission/memory.ts:138

Implements

Constructors

Constructor

ts
new MemoryAdmissionScheduler(options): MemoryAdmissionScheduler;

Defined in: packages/core/src/admission/memory.ts:146

Parameters

ParameterType
optionsMemoryAdmissionOptions

Returns

MemoryAdmissionScheduler

Methods

cancel()

ts
cancel(
   unitId, 
   generation, 
opId): Promise<void>;

Defined in: packages/core/src/admission/memory.ts:623

Cancels a queued ticket (nothing to refund); granted ones release.

Parameters

ParameterType
unitIdstring
generationstring
opIdstring

Returns

Promise&lt;void&gt;

Implementation of

AdmissionScheduler.cancel


checkpointCover()

ts
checkpointCover(
   unitId, 
   generation, 
   cover, 
opId): Promise<void>;

Defined in: packages/core/src/admission/memory.ts:566

Durably checkpoints a consumption cover BEFORE the covered batch (the intent-before-effect doctrine applied to capacity): monotone high-water, idempotent by opId, and lease-carried: a fenced store rejects an expired lease's cover write, which is what makes the conservative expiry refund provable rather than optimistic.

Parameters

ParameterType
unitIdstring
generationstring
coverAdmissionReservation
opIdstring

Returns

Promise&lt;void&gt;

Implementation of

AdmissionScheduler.checkpointCover


enqueue()

ts
enqueue(request, opId): Promise<AdmissionTicketDecision>;

Defined in: packages/core/src/admission/memory.ts:387

Conditional create by (unitId, generation) plus immediate grant when every matched level admits; opId makes retries idempotent.

Parameters

ParameterType
requestAdmissionRequest
opIdstring

Returns

Promise&lt;AdmissionTicketDecision&gt;

Implementation of

AdmissionScheduler.enqueue


pump()

ts
pump(_opId): Promise<AdmissionTicket[]>;

Defined in: packages/core/src/admission/memory.ts:695

Advances the scheduler: expires stale leases (conservative settlement), then grants queued tickets in SFQ order while every matched level admits. Returns the newly granted tickets.

Parameters

ParameterType
_opIdstring

Returns

Promise&lt;AdmissionTicket[]&gt;

Implementation of

AdmissionScheduler.pump


rebind()

ts
rebind(
   unitId, 
   generation, 
   target, 
opId): Promise<AdmissionTicketDecision>;

Defined in: packages/core/src/admission/memory.ts:643

The failover transfer (RFC section 4.2, item 4): atomically acquires the TARGET hierarchy's capacity and level-2 slot and releases the source hierarchy in the same transition, BEFORE the target dispatches. A failed transfer leaves the source binding unchanged and the target undispatchable: no window exists in which work runs on a provider account whose slot it never held.

Parameters

ParameterType
unitIdstring
generationstring
target{ scope: AdmissionScopeDimensions; }
target.scopeAdmissionScopeDimensions
opIdstring

Returns

Promise&lt;AdmissionTicketDecision&gt;

Implementation of

AdmissionScheduler.rebind


recover()

ts
recover(
   unitId, 
   generation, 
opId): Promise<AdmissionRecovery>;

Defined in: packages/core/src/admission/memory.ts:541

The resumed unit's recovery: granted renews the lease, a queued ticket reports its surviving position, and unknown means re-enqueue (the conservative direction).

Parameters

ParameterType
unitIdstring
generationstring
opIdstring

Returns

Promise&lt;AdmissionRecovery&gt;

Implementation of

AdmissionScheduler.recover


release()

ts
release(
   unitId, 
   generation, 
   actuals, 
opId): Promise<void>;

Defined in: packages/core/src/admission/memory.ts:588

Release with actuals: the unused remainder refunds to each level, over-consumption beyond the reservation lands as bucket debt (it never denies retroactively), and a late settlement after expiry is accepted idempotently as debt rather than discarded.

Parameters

ParameterType
unitIdstring
generationstring
actualsAdmissionReservation
opIdstring

Returns

Promise&lt;void&gt;

Implementation of

AdmissionScheduler.release


renew()

ts
renew(
   unitId, 
   generation, 
_opId): Promise<void>;

Defined in: packages/core/src/admission/memory.ts:558

Renews a granted ticket's lease; unknown tickets are no-ops.

Parameters

ParameterType
unitIdstring
generationstring
_opIdstring

Returns

Promise&lt;void&gt;

Implementation of

AdmissionScheduler.renew


snapshot()

ts
snapshot(): AdmissionState;

Defined in: packages/core/src/admission/memory.ts:186

The whole state as a plain-JSON document (deep-copied).

Returns

AdmissionState