@xandreed/plugin-tasks 0.12.0 → 0.14.0
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/README.md +1 -1
- package/dist/plugin.adapter.js +1 -1
- package/dist/task-runner.adapter.d.ts +10 -2
- package/dist/task-runner.adapter.js +8 -8
- package/dist/task-runner.adapter.test.d.ts +1 -0
- package/dist/tasks.adapter.js +1 -0
- package/dist/tasks.conformance.test.d.ts +1 -0
- package/package.json +7 -7
package/README.md
CHANGED
package/dist/plugin.adapter.js
CHANGED
|
@@ -5,7 +5,7 @@ import { TasksConfig, tasksDefaults } from "./task-records.entity.js";
|
|
|
5
5
|
import { TasksLive } from "./tasks.adapter.js";
|
|
6
6
|
export const tasksPlugin = definePlugin({
|
|
7
7
|
id: "@xandreed/plugin-tasks",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.14.0",
|
|
9
9
|
scope: "runtime",
|
|
10
10
|
config: TasksConfig,
|
|
11
11
|
defaults: tasksDefaults,
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { TaskRunner } from "@xandreed/core";
|
|
2
|
+
import { TaskActivity, TaskRunner } from "@xandreed/core";
|
|
3
3
|
/**
|
|
4
4
|
* Background work on fibers of this process, each on its own fiber (it
|
|
5
5
|
* keeps none of the starting turn's services), all interrupted when the
|
|
6
6
|
* layer's scope closes: an interrupted task's turn ends as interrupted.
|
|
7
7
|
* With `maxMs`, each piece of work must be done that long after it starts.
|
|
8
|
+
* The work runs with the services the layer was built with, its trace state
|
|
9
|
+
* included (no `replayableContext`: a new fiber has no other): its spans nest
|
|
10
|
+
* under the span current where the layer was built, and it reads the
|
|
11
|
+
* `CurrentTraceContent` set there.
|
|
12
|
+
* It also provides `TaskActivity`: the work running now, counted from the
|
|
13
|
+
* moment `run` hands it over until it ends. The fiber is forked and joins
|
|
14
|
+
* the set in one step, so a caller interrupted as it hands work over leaves
|
|
15
|
+
* none running outside the set (uncounted, and not interrupted with it).
|
|
8
16
|
*/
|
|
9
17
|
export declare const InProcessTaskRunnerLive: (options?: {
|
|
10
18
|
readonly maxMs?: number;
|
|
11
|
-
}) => Layer.Layer<TaskRunner>;
|
|
19
|
+
}) => Layer.Layer<TaskRunner | TaskActivity>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Clock, Effect, FiberSet, Layer, Option } from "effect";
|
|
2
|
-
import { TaskRunner } from "@xandreed/core";
|
|
3
|
-
export const InProcessTaskRunnerLive = (options) => Layer.
|
|
4
|
-
const fibers = yield* FiberSet.make(), context = yield* Effect.context()
|
|
5
|
-
return TaskRunner.of({
|
|
1
|
+
import { Clock, Context, Effect, FiberSet, Layer, Option } from "effect";
|
|
2
|
+
import { TaskActivity, TaskRunner } from "@xandreed/core";
|
|
3
|
+
export const InProcessTaskRunnerLive = (options) => Layer.effectContext(Effect.gen(function* () {
|
|
4
|
+
const fibers = yield* FiberSet.make(), context = yield* Effect.context(), runner = TaskRunner.of({
|
|
6
5
|
run: (work) => Effect.gen(function* () {
|
|
7
|
-
const now = yield* Clock.currentTimeMillis, deadline = Option.map(Option.fromNullishOr(options?.maxMs), (ms) => now + ms)
|
|
8
|
-
yield* FiberSet.
|
|
6
|
+
const now = yield* Clock.currentTimeMillis, deadline = Option.map(Option.fromNullishOr(options?.maxMs), (ms) => now + ms);
|
|
7
|
+
yield* Effect.sync(() => FiberSet.addUnsafe(fibers, Effect.runForkWith(context)(work(deadline))));
|
|
9
8
|
})
|
|
10
|
-
});
|
|
9
|
+
}), activity = TaskActivity.of({ running: FiberSet.size(fibers), idle: FiberSet.awaitEmpty(fibers) });
|
|
10
|
+
return Context.make(TaskRunner, runner).pipe(Context.add(TaskActivity, activity));
|
|
11
11
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/tasks.adapter.js
CHANGED
|
@@ -58,6 +58,7 @@ export const TasksLive = (config) => Layer.effect(Tasks, Effect.gen(function* ()
|
|
|
58
58
|
TurnDuplicate: () => Effect.void,
|
|
59
59
|
KeyConflict: () => Effect.void,
|
|
60
60
|
NothingPending: () => Effect.void,
|
|
61
|
+
NotResumable: () => Effect.void,
|
|
61
62
|
TurnRefused: (refused) => recordEnd(child, {
|
|
62
63
|
taskId: task.taskId,
|
|
63
64
|
outcome: "failed",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xandreed/plugin-tasks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=24",
|
|
6
|
+
"bun": ">=1.3.0"
|
|
7
|
+
},
|
|
4
8
|
"type": "module",
|
|
5
9
|
"main": "./dist/index.js",
|
|
6
10
|
"exports": {
|
|
@@ -10,8 +14,8 @@
|
|
|
10
14
|
}
|
|
11
15
|
},
|
|
12
16
|
"dependencies": {
|
|
13
|
-
"@xandreed/core": "0.
|
|
14
|
-
"effect": "4.0.
|
|
17
|
+
"@xandreed/core": "0.14.0",
|
|
18
|
+
"effect": "4.0.7"
|
|
15
19
|
},
|
|
16
20
|
"private": false,
|
|
17
21
|
"types": "./dist/index.d.ts",
|
|
@@ -22,9 +26,5 @@
|
|
|
22
26
|
"README.md",
|
|
23
27
|
"LICENSE"
|
|
24
28
|
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=24",
|
|
27
|
-
"bun": ">=1.3.0"
|
|
28
|
-
},
|
|
29
29
|
"license": "MIT"
|
|
30
30
|
}
|