@empyria/restate 0.1.2 → 0.1.3
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/lib/Admin.js +16 -0
- package/package.json +6 -5
- package/test/Admin.test.js +13 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ import { checkServiceHandler } from '@empyria/restate/lib/Admin.js'
|
|
|
45
45
|
|
|
46
46
|
| Module | Purpose |
|
|
47
47
|
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
-
| [lib/Admin.js](./lib/Admin.js) | Restate Admin API client — service/handler discovery, deployment registration and teardown, workflow/message dispatch, and `setupRestate` for wiring up an endpoint with health checks and graceful shutdown. |
|
|
48
|
+
| [lib/Admin.js](./lib/Admin.js) | Restate Admin API client — service/handler discovery, deployment registration and teardown, workflow/message dispatch, `defineWorkflow`/`defineService`/`defineObject`/`definePubsub` construct definers, and `setupRestate` for wiring up an endpoint with health checks and graceful shutdown. |
|
|
49
49
|
| [lib/Caller.js](./lib/Caller.js) | `CallerServiceDef` — a generic Restate service that dispatches a call to any handler on any other service by name, for when the target isn't known at compile time. |
|
|
50
50
|
| [lib/Cron.js](./lib/Cron.js) | `cronJobInitiator`/`cronJob` — Restate services implementing cron-driven, replay-safe recurring job scheduling on top of `croner`. |
|
|
51
51
|
| [lib/Validation.js](./lib/Validation.js) | `withValidation` — wraps a workflow handler with input/output JSON schema validation via `@empyria/common`. |
|
package/lib/Admin.js
CHANGED
|
@@ -6,6 +6,7 @@ import { setTimeout as sleep } from 'timers/promises'
|
|
|
6
6
|
|
|
7
7
|
import * as restate from '@restatedev/restate-sdk'
|
|
8
8
|
import * as clients from '@restatedev/restate-sdk-clients'
|
|
9
|
+
import { createPubsubObject } from '@restatedev/pubsub'
|
|
9
10
|
|
|
10
11
|
export { restate, clients }
|
|
11
12
|
|
|
@@ -437,6 +438,21 @@ export function defineObject(def) {
|
|
|
437
438
|
return restate.object(def)
|
|
438
439
|
}
|
|
439
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Typed wrapper around `@restatedev/pubsub`'s `createPubsubObject`; see {@link defineWorkflow}.
|
|
443
|
+
* Unlike `defineWorkflow`/`defineService`/`defineObject`, there's no handler map to write —
|
|
444
|
+
* `createPubsubObject` returns a complete `VirtualObjectDefinition` on its own (pull/publish/
|
|
445
|
+
* subscribe/truncate), so this exists purely for the same "one `define*` per Restate construct"
|
|
446
|
+
* naming consistency, not to add behavior. Register the result alongside your other
|
|
447
|
+
* services/objects on the same endpoint (see `setupRestate`'s `services` param) — that's what
|
|
448
|
+
* makes the endpoint's ingress serve `/pubsub/<topic>` as an SSE stream for it.
|
|
449
|
+
* @param {Parameters<typeof createPubsubObject>[0]} name
|
|
450
|
+
* @param {Parameters<typeof createPubsubObject>[1]} [options]
|
|
451
|
+
*/
|
|
452
|
+
export function definePubsub(name, options) {
|
|
453
|
+
return createPubsubObject(name, options)
|
|
454
|
+
}
|
|
455
|
+
|
|
440
456
|
/**
|
|
441
457
|
* Starts the HTTP/2 Restate endpoint, a health-check HTTP server, registers
|
|
442
458
|
* the deployment with the admin API, and wires SIGTERM/SIGINT for graceful
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empyria/restate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Restate.dev helpers for the Empyria nanoservice framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Imre Fazekas <imre.fazekas@icloud.com>",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@empyria/classification": "0.1.2",
|
|
28
28
|
"@empyria/common": "0.1.2",
|
|
29
|
-
"@restatedev/
|
|
30
|
-
"@restatedev/restate-sdk
|
|
31
|
-
"@restatedev/restate-sdk-
|
|
29
|
+
"@restatedev/pubsub": "0.3.2",
|
|
30
|
+
"@restatedev/restate-sdk": "1.16.8",
|
|
31
|
+
"@restatedev/restate-sdk-clients": "1.16.8",
|
|
32
|
+
"@restatedev/restate-sdk-core": "1.16.8",
|
|
32
33
|
"croner": "10.0.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@restatedev/restate-server": "1.7.
|
|
36
|
+
"@restatedev/restate-server": "1.7.6",
|
|
36
37
|
"oxfmt": "0.64.0",
|
|
37
38
|
"oxlint": "1.79.0"
|
|
38
39
|
},
|
package/test/Admin.test.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
defineWorkflow,
|
|
21
21
|
defineService,
|
|
22
22
|
defineObject,
|
|
23
|
+
definePubsub,
|
|
23
24
|
createRestateAdmin,
|
|
24
25
|
restate,
|
|
25
26
|
clients,
|
|
@@ -455,6 +456,18 @@ describe('defineWorkflow / defineService / defineObject', () => {
|
|
|
455
456
|
})
|
|
456
457
|
})
|
|
457
458
|
|
|
459
|
+
describe('definePubsub', () => {
|
|
460
|
+
test('is a passthrough to createPubsubObject, name and all', () => {
|
|
461
|
+
const pubsub = definePubsub('pubsub')
|
|
462
|
+
expect(pubsub.name).toBe('pubsub')
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
test('forwards options (e.g. pullTimeout) to createPubsubObject', () => {
|
|
466
|
+
const pubsub = definePubsub('pubsub', { pullTimeout: { seconds: 30 } })
|
|
467
|
+
expect(pubsub.name).toBe('pubsub')
|
|
468
|
+
})
|
|
469
|
+
})
|
|
470
|
+
|
|
458
471
|
describe('createRestateAdmin', () => {
|
|
459
472
|
test('binds restateAdminURL/restateURL across its methods', async () => {
|
|
460
473
|
globalThis.fetch = mock(async (url) => {
|