@yielded/agent-platform-cloudflare 0.1.0-beta.175 → 0.1.0-beta.176
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.
- package/dist/{Alarm-B44efvB1.mjs → Alarm-7uipp6LW.mjs} +45 -44
- package/dist/Alarm-7uipp6LW.mjs.map +1 -0
- package/dist/Alarm.mjs +1 -1
- package/dist/CloudflareScheduling.mjs +2 -2
- package/dist/CloudflareSubscriptions.mjs +2 -2
- package/dist/{CloudflareThreadClient-Ai3MTs3X.mjs → CloudflareThreadClient-bA3lGA_2.mjs} +2 -2
- package/dist/{CloudflareThreadClient-Ai3MTs3X.mjs.map → CloudflareThreadClient-bA3lGA_2.mjs.map} +1 -1
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{ThreadObject-DGvlHWYi.mjs → ThreadObject-SNcCsrS2.mjs} +15 -12
- package/dist/ThreadObject-SNcCsrS2.mjs.map +1 -0
- package/dist/ThreadObject.mjs +1 -1
- package/dist/WakeScheduler.mjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{prepared-admission-DYdffQ8K.mjs → prepared-admission-BvMiFR41.mjs} +2 -2
- package/dist/{prepared-admission-DYdffQ8K.mjs.map → prepared-admission-BvMiFR41.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +84 -85
- package/src/internal/layers.ts +69 -48
- package/dist/Alarm-B44efvB1.mjs.map +0 -1
- package/dist/ThreadObject-DGvlHWYi.mjs.map +0 -1
|
@@ -410,49 +410,48 @@ const makeAlarmOperation = Effect.gen(function* () {
|
|
|
410
410
|
const queue = make(ctx.storage);
|
|
411
411
|
const transaction = (body) => alarms.transaction((mutations) => Effect.withFiber((owner) => {
|
|
412
412
|
let active = true;
|
|
413
|
-
|
|
414
|
-
operation: "enroll maintenance source",
|
|
415
|
-
message: "Source intent requires its active transaction callback's fiber"
|
|
416
|
-
})));
|
|
417
|
-
return body.pipe(Effect.provideService(CurrentCheckpoint, {
|
|
413
|
+
return Effect.onExitPrimitive(body(owner).pipe(Effect.provideService(CurrentCheckpoint, {
|
|
418
414
|
mutations,
|
|
419
|
-
|
|
420
|
-
}),
|
|
415
|
+
isActive: (fiber) => active && fiber === owner
|
|
416
|
+
})), () => {
|
|
421
417
|
active = false;
|
|
422
|
-
})
|
|
418
|
+
});
|
|
423
419
|
}), { sqlClient: sql }).pipe(Effect.mapError((cause) => cause instanceof DurableObjectStorage.StorageOperationError ? SqlError.make({ reason: UnknownError.make({
|
|
424
420
|
operation: "commit maintenance checkpoint",
|
|
425
421
|
message: "Source facts and maintenance checkpoint could not commit",
|
|
426
422
|
cause
|
|
427
423
|
}) }) : cause));
|
|
428
|
-
const withTransaction = (body) => Effect.
|
|
424
|
+
const withTransaction = (body) => Effect.withFiber((fiber) => {
|
|
425
|
+
const ambient = Context.getOption(fiber.context, sql.transactionService);
|
|
429
426
|
if (ambient._tag === "Some" && !ownsTransaction(ctx.storage, ambient.value[1])) return Effect.fail(SqlError.make({ reason: UnknownError.make({
|
|
430
427
|
operation: "begin maintenance source transaction",
|
|
431
428
|
message: "Use ThreadMutationGate.withTransaction at the outermost source transaction",
|
|
432
429
|
cause: "Unwrapped SQL transaction cannot own buffered maintenance intent"
|
|
433
430
|
}) }));
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
431
|
+
let frame;
|
|
432
|
+
return Effect.uninterruptibleMask((restore) => Effect.onExitPrimitive(transaction((owner) => {
|
|
433
|
+
const current = Context.getOption(owner.context, sql.transactionService);
|
|
434
|
+
if (current._tag === "None") return SqlError.make({ reason: UnknownError.make({
|
|
435
|
+
operation: "begin maintenance source transaction",
|
|
436
|
+
message: "SQL transaction unavailable",
|
|
437
|
+
cause: "SQL transaction unavailable"
|
|
438
|
+
}) });
|
|
439
|
+
const started = queue.begin(current.value[1]);
|
|
440
|
+
frame = started;
|
|
441
|
+
return Effect.flatMap(restore(body), (value) => Effect.try({
|
|
444
442
|
try: () => {
|
|
445
|
-
|
|
443
|
+
queue.flush(started);
|
|
444
|
+
return value;
|
|
446
445
|
},
|
|
447
446
|
catch: (cause) => SqlError.make({ reason: UnknownError.make({
|
|
448
447
|
cause,
|
|
449
448
|
operation: "flush maintenance due queue",
|
|
450
449
|
message: "Maintenance intent could not commit"
|
|
451
450
|
}) })
|
|
452
|
-
}))
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}));
|
|
451
|
+
}));
|
|
452
|
+
}), (exit) => {
|
|
453
|
+
if (frame !== void 0) queue.finish(frame, Exit.isSuccess(exit));
|
|
454
|
+
}).pipe(Effect.provideService(Scheduler.PreventSchedulerYield, true)));
|
|
456
455
|
}).pipe(Effect.provideService(SqlClient, sql));
|
|
457
456
|
const run = (operation, execute) => {
|
|
458
457
|
const commit = Effect.withFiber((fiber) => {
|
|
@@ -461,28 +460,30 @@ const makeAlarmOperation = Effect.gen(function* () {
|
|
|
461
460
|
operation: "checkpoint",
|
|
462
461
|
message: "Maintenance checkpoint transaction unavailable"
|
|
463
462
|
}));
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
463
|
+
if (!tx.isActive(fiber)) return Effect.fail(DurableAlarmError.make({
|
|
464
|
+
operation: "enroll maintenance source",
|
|
465
|
+
message: "Source intent requires its active transaction callback's fiber"
|
|
466
|
+
}));
|
|
467
|
+
let checkpoint = Effect.void;
|
|
468
|
+
const intent = {
|
|
469
|
+
at: (at) => {
|
|
470
|
+
checkpoint = tx.mutations.scheduleAlarm(maintenanceAlarmInput(at));
|
|
471
|
+
},
|
|
472
|
+
earlier: (at) => {
|
|
473
|
+
checkpoint = tx.mutations.scheduleAlarmEarlier(maintenanceAlarmInput(at));
|
|
474
|
+
},
|
|
475
|
+
cancel: () => {
|
|
476
|
+
checkpoint = tx.mutations.cancelAlarm(maintenanceAlarmRef);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
return Effect.tryPromise({
|
|
480
|
+
try: () => execute(ctx.storage, intent),
|
|
481
|
+
catch: alarmFailure(operation)
|
|
482
|
+
}).pipe(Effect.tap(() => checkpoint));
|
|
482
483
|
});
|
|
483
484
|
return Effect.withFiber((fiber) => {
|
|
484
485
|
if (fiber.getRef(CurrentCheckpoint) !== void 0) return commit;
|
|
485
|
-
return Context.getOption(fiber.context, sql.transactionService)._tag === "Some" && !buffering(ctx.storage) ? transaction(commit).pipe(Effect.ensuring(Effect.sync(() => invalidate(ctx.storage)))) : withTransaction(commit);
|
|
486
|
+
return Context.getOption(fiber.context, sql.transactionService)._tag === "Some" && !buffering(ctx.storage) ? transaction(() => commit).pipe(Effect.ensuring(Effect.sync(() => invalidate(ctx.storage)))) : withTransaction(commit);
|
|
486
487
|
}).pipe(Effect.uninterruptible, Effect.mapError(alarmFailure(operation)));
|
|
487
488
|
};
|
|
488
489
|
return {
|
|
@@ -1896,4 +1897,4 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
1896
1897
|
//#endregion
|
|
1897
1898
|
export { Lifecycle as _, ThreadHostMaintenance as a, Projection as b, ThreadMaintenanceFailpoint as c, ThreadNativeMaintenance as d, ThreadPublication as f, HostLaneId as g, publishCommitted as h, MaintenancePassReport as i, ThreadMessageDelivery as l, ThreadRecoveryFaultEvent as m, DurableAlarmError as n, ThreadMaintenance as o, ThreadRecoveryEvents as p, DurableAlarmService as r, ThreadMaintenanceAlarm as s, Alarm_exports as t, ThreadMutationGate as u, Messages as v, Publication as x, Native as y };
|
|
1898
1899
|
|
|
1899
|
-
//# sourceMappingURL=Alarm-
|
|
1900
|
+
//# sourceMappingURL=Alarm-7uipp6LW.mjs.map
|