@danypops/papyrus 0.60.3 → 0.60.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.
package/package.json
CHANGED
package/src/daemon/daemon.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { PushChannel } from "@danypops/vehicle-server/push-channel";
|
|
|
11
11
|
import { DAEMON_HOST, DB_OPTIMIZE_INTERVAL_MS, dbPath, metricsPath, WAL_CHECKPOINT_INTERVAL_MS } from "../constants.ts";
|
|
12
12
|
import { logEvent, logger } from "../log/log.ts";
|
|
13
13
|
import { createApp, createPapyrusService } from "../service.ts";
|
|
14
|
+
import { createTaskMutationPushMiddleware } from "./task-mutation-push.ts";
|
|
14
15
|
import {
|
|
15
16
|
clearDaemonPort,
|
|
16
17
|
clearSharedVehicleHandle,
|
|
@@ -81,6 +82,7 @@ export async function serveMain(): Promise<void> {
|
|
|
81
82
|
service.vehicle.useExecutionMiddleware(createVehicleMetricsMiddleware(vehicleMetrics, "papyrus"));
|
|
82
83
|
registerVehicleMetricsOperations(service.vehicle, vehicleMetrics, "papyrus");
|
|
83
84
|
const pushChannel = new PushChannel({ token });
|
|
85
|
+
service.vehicle.useExecutionMiddleware(createTaskMutationPushMiddleware((operation) => pushChannel.publish("tasks", { operation })));
|
|
84
86
|
const app = createApp({
|
|
85
87
|
service,
|
|
86
88
|
token,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { VehicleExecutionMiddleware } from "@danypops/vehicle-server";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Publishes one invalidation only after a successful Vehicle task mutation.
|
|
5
|
+
* Kept as execution middleware so HTTP, LocalVehicleClient, jobs, and future
|
|
6
|
+
* transports all observe the same mutation rather than each transport trying
|
|
7
|
+
* to infer success from its own response framing.
|
|
8
|
+
*/
|
|
9
|
+
export function createTaskMutationPushMiddleware(publish: (operation: string) => void): VehicleExecutionMiddleware {
|
|
10
|
+
return {
|
|
11
|
+
id: "papyrus.task-mutation-push",
|
|
12
|
+
async intercept(request, next) {
|
|
13
|
+
const output = await next(request.input);
|
|
14
|
+
if (request.operation.name.startsWith("tasks.") && request.operation.effect !== "read") publish(request.operation.name);
|
|
15
|
+
return output;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|