@fedify/cfworkers 2.2.0-dev.677 → 2.2.0-dev.692

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.
Files changed (2) hide show
  1. package/README.md +18 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -16,7 +16,7 @@ implementations for [Cloudflare Workers]:
16
16
  - [`WorkersMessageQueue`]
17
17
 
18
18
  ~~~~ typescript
19
- import type { Federation } from "@fedify/fedify";
19
+ import { createFederation, type Message } from "@fedify/fedify";
20
20
  import { WorkersKvStore, WorkersMessageQueue } from "@fedify/cfworkers";
21
21
 
22
22
  export default {
@@ -26,22 +26,25 @@ export default {
26
26
  queue: new WorkersMessageQueue(env.QUEUE_BINDING),
27
27
  // ... other options
28
28
  });
29
-
30
- return federation.handle(request, { contextData: env });
29
+
30
+ return federation.fetch(request, { contextData: env });
31
31
  },
32
-
32
+
33
33
  async queue(batch, env, ctx) {
34
34
  const federation = createFederation({
35
35
  kv: new WorkersKvStore(env.KV_BINDING),
36
36
  queue: new WorkersMessageQueue(env.QUEUE_BINDING),
37
37
  // ... other options
38
38
  });
39
-
39
+
40
40
  for (const message of batch.messages) {
41
- await federation.processQueuedTask(message.body);
41
+ await federation.processQueuedTask(
42
+ env,
43
+ message.body as unknown as Message,
44
+ );
42
45
  }
43
46
  }
44
- } satisfies ExportedHandler<{
47
+ } satisfies ExportedHandler<{
45
48
  KV_BINDING: KVNamespace<string>;
46
49
  QUEUE_BINDING: Queue;
47
50
  }>;
@@ -101,6 +104,14 @@ management.
101
104
  > process the messages. The `queue()` method is the only way to consume
102
105
  > messages from the queue in Cloudflare Workers.
103
106
 
107
+ > [!NOTE]
108
+ > If you use `orderingKey` when enqueueing messages, construct
109
+ > `WorkersMessageQueue` with an `orderingKv` namespace and pass each raw queue
110
+ > message through `WorkersMessageQueue.processMessage()` before calling
111
+ > `Federation.processQueuedTask()`. This acquires and releases the best-effort
112
+ > ordering lock for that key. You can also customize the lock behavior with
113
+ > the `orderingKeyPrefix` and `orderingLockTtl` options.
114
+
104
115
  [Cloudflare Queues]: https://developers.cloudflare.com/queues/
105
116
 
106
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/cfworkers",
3
- "version": "2.2.0-dev.677+41046619",
3
+ "version": "2.2.0-dev.692+12c62883",
4
4
  "description": "Adapt Fedify with Cloudflare Workers",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "peerDependencies": {
54
54
  "@cloudflare/workers-types": "^4.20250906.0",
55
- "@fedify/fedify": "^2.2.0-dev.677+41046619"
55
+ "@fedify/fedify": "^2.2.0-dev.692+12c62883"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@cloudflare/vitest-pool-workers": "^0.8.31",