feat(run-engine): concurrency-key virtual-time key builders
Task 1 of the CK virtual-time (SFQ) scheduling plan. Adds ckVtimeKeyFromQueue and ckVtimeFloorKeyFromQueue (reusing the same base-queue normalisation as ckIndexKeyFromQueue, so :ck:* and :ck:<value> map to one base key), the RunQueueKeyProducer interface signatures, and byte-exact key tests. No runtime behaviour yet.
This commit is contained in:
@@ -22,6 +22,8 @@ const constants = {
|
||||
MASTER_QUEUE_PART: "masterQueue",
|
||||
WORKER_QUEUE_PART: "workerQueue",
|
||||
CK_INDEX_PART: "ckIndex",
|
||||
CK_VTIME_PART: "ckVtime",
|
||||
CK_VTIME_FLOOR_PART: "ckVtimeFloor",
|
||||
LENGTH_COUNTER_PART: "lengthCounter",
|
||||
RUNNING_COUNTER_PART: "runningCounter",
|
||||
} as const;
|
||||
@@ -315,6 +317,14 @@ export class RunQueueFullKeyProducer implements RunQueueKeyProducer {
|
||||
return `${this.baseQueueKeyFromQueue(queue)}:${constants.CK_INDEX_PART}`;
|
||||
}
|
||||
|
||||
ckVtimeKeyFromQueue(queue: string): string {
|
||||
return `${this.baseQueueKeyFromQueue(queue)}:${constants.CK_VTIME_PART}`;
|
||||
}
|
||||
|
||||
ckVtimeFloorKeyFromQueue(queue: string): string {
|
||||
return `${this.baseQueueKeyFromQueue(queue)}:${constants.CK_VTIME_FLOOR_PART}`;
|
||||
}
|
||||
|
||||
// indexOf instead of /:ck:.+$/ (queue names are user-controlled; polynomial regex).
|
||||
// Only strips when at least one character follows ":ck:", matching the old semantics.
|
||||
baseQueueKeyFromQueue(queue: string): string {
|
||||
|
||||
@@ -432,4 +432,19 @@ describe("KeyProducer", () => {
|
||||
"{org:o1234}:proj:p1234:env:e1234:queue:task/foo:ck:*"
|
||||
);
|
||||
});
|
||||
|
||||
it("produces ckVtime keys from a CK variant queue name", () => {
|
||||
const keys = new RunQueueFullKeyProducer();
|
||||
const q = "{org:o1}:proj:p1:env:e1:queue:task/my-task:ck:tenant-a";
|
||||
expect(keys.ckVtimeKeyFromQueue(q)).toBe(
|
||||
"{org:o1}:proj:p1:env:e1:queue:task/my-task:ckVtime"
|
||||
);
|
||||
expect(keys.ckVtimeFloorKeyFromQueue(q)).toBe(
|
||||
"{org:o1}:proj:p1:env:e1:queue:task/my-task:ckVtimeFloor"
|
||||
);
|
||||
// ck wildcard and base-queue inputs normalise the same way
|
||||
expect(keys.ckVtimeKeyFromQueue(q.replace(":ck:tenant-a", ":ck:*"))).toBe(
|
||||
keys.ckVtimeKeyFromQueue(q)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,6 +132,8 @@ export interface RunQueueKeyProducer {
|
||||
|
||||
// CK index methods
|
||||
ckIndexKeyFromQueue(queue: string): string;
|
||||
ckVtimeKeyFromQueue(queue: string): string;
|
||||
ckVtimeFloorKeyFromQueue(queue: string): string;
|
||||
baseQueueKeyFromQueue(queue: string): string;
|
||||
isCkWildcard(queue: string): boolean;
|
||||
toCkWildcard(queue: string): string;
|
||||
|
||||
Reference in New Issue
Block a user