@hotmeshio/long-tail 0.28.3 → 0.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -141,7 +141,7 @@ function planJob(state, m, b, at, ttl) {
|
|
|
141
141
|
const released = releasedAction(row, m, b);
|
|
142
142
|
if (b.result === protocol_1.JOB_RESULT.OK)
|
|
143
143
|
return ack([released]);
|
|
144
|
-
return ack([released, ...(0, plan_shared_1.failHandoff)(state, row, m, {
|
|
144
|
+
return ack([(0, plan_shared_1.holdForResolver)(row, m), released, ...(0, plan_shared_1.failHandoff)(state, row, m, {
|
|
145
145
|
received: false, unitId, errorCode: contracts_1.HANDOFF_ERROR.SENDER_REJECTED, result: b.result, reason: b.reason ?? null,
|
|
146
146
|
detail: `${m} finished ${unitId}: ${b.result}${b.reason ? ` (${b.reason})` : ''}`,
|
|
147
147
|
})]);
|
|
@@ -18,3 +18,11 @@ export declare function cancelDispatch(state: GatewayState, row: HandoffRow): Ac
|
|
|
18
18
|
* claimant may resolve a claimed row); `reportedBy` names who saw the failure.
|
|
19
19
|
*/
|
|
20
20
|
export declare function failHandoff(state: GatewayState, row: HandoffRow, reporter: Actor, resolution: HandoffResolution): Action[];
|
|
21
|
+
/** Who resolves a failed handoff: the receiver while it holds the claim, otherwise whoever reports. */
|
|
22
|
+
export declare function resolverOf(row: HandoffRow, reporter: Actor): Actor;
|
|
23
|
+
/**
|
|
24
|
+
* The row claimed for its resolver before anything else is written to it. A
|
|
25
|
+
* claimed row refuses every other resolver, so what the machine writes next
|
|
26
|
+
* and the resolution that follows land on a row nobody else can end meanwhile.
|
|
27
|
+
*/
|
|
28
|
+
export declare function holdForResolver(row: HandoffRow, reporter: Actor): Action;
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cancelJobs = cancelJobs;
|
|
4
4
|
exports.cancelDispatch = cancelDispatch;
|
|
5
5
|
exports.failHandoff = failHandoff;
|
|
6
|
+
exports.resolverOf = resolverOf;
|
|
7
|
+
exports.holdForResolver = holdForResolver;
|
|
6
8
|
const contracts_1 = require("../contracts");
|
|
7
9
|
const protocol_1 = require("../../../lib/machines/protocol");
|
|
8
10
|
const jobs_1 = require("./jobs");
|
|
@@ -32,7 +34,19 @@ function cancelDispatch(state, row) {
|
|
|
32
34
|
* claimant may resolve a claimed row); `reportedBy` names who saw the failure.
|
|
33
35
|
*/
|
|
34
36
|
function failHandoff(state, row, reporter, resolution) {
|
|
35
|
-
const claimant = row
|
|
37
|
+
const claimant = resolverOf(row, reporter);
|
|
36
38
|
const payload = claimant === reporter ? { ...resolution } : { ...resolution, reportedBy: reporter };
|
|
37
39
|
return [{ kind: 'resolve', as: claimant, rowId: row.id, payload }, ...cancelDispatch(state, row)];
|
|
38
40
|
}
|
|
41
|
+
/** Who resolves a failed handoff: the receiver while it holds the claim, otherwise whoever reports. */
|
|
42
|
+
function resolverOf(row, reporter) {
|
|
43
|
+
return row.dispatch === state_1.DISPATCH_STATE.ACCEPTED && row.toMachine ? row.toMachine : reporter;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The row claimed for its resolver before anything else is written to it. A
|
|
47
|
+
* claimed row refuses every other resolver, so what the machine writes next
|
|
48
|
+
* and the resolution that follows land on a row nobody else can end meanwhile.
|
|
49
|
+
*/
|
|
50
|
+
function holdForResolver(row, reporter) {
|
|
51
|
+
return { kind: 'claim', as: resolverOf(row, reporter), rowId: row.id };
|
|
52
|
+
}
|
package/docs/machines.md
CHANGED
|
@@ -115,7 +115,7 @@ When a sender finishes a unit, the gateway records the release on the row and, i
|
|
|
115
115
|
| `trace` | One entry per unit: `{ unitId, machineId, jobId, result, materials: [{ material, lot }] }` |
|
|
116
116
|
| `lots` | Every lot those units consumed, once each |
|
|
117
117
|
|
|
118
|
-
Both are containment-searchable, so the rows that used a lot, and with them the units, are one query: `GET /escalations?facets={"lots":["LOT-7"]}`. A unit's whole path is every handoff row whose `units` holds it. The sender's full finished record stays on the row as its `released:<unit>` item. A codec maps its own lot fields into `materials`.
|
|
118
|
+
Both are containment-searchable, so the rows that used a lot, and with them the units, are one query: `GET /escalations?facets={"lots":["LOT-7"]}`. A unit's whole path is every handoff row whose `units` holds it. The sender's full finished record stays on the row as its `released:<unit>` item. When that record is not ok, the row is first claimed for the machine that resolves it, so the record and the `sender-rejected` resolution land on a row no receiver can end in between. A codec maps its own lot fields into `materials`.
|
|
119
119
|
|
|
120
120
|
### Job lifecycle on the row
|
|
121
121
|
|
package/package.json
CHANGED