@effectstream/runtime 0.103.2 → 0.104.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/runtime",
3
- "version": "0.103.2",
3
+ "version": "0.104.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -13,17 +13,17 @@
13
13
  },
14
14
  "exports": "./src/mod.ts",
15
15
  "dependencies": {
16
- "@effectstream/concise": "0.103.2",
17
- "@effectstream/config": "0.103.2",
18
- "@effectstream/coroutine": "0.103.2",
19
- "@effectstream/crypto": "0.103.2",
20
- "@effectstream/db": "0.103.2",
21
- "@effectstream/event-client": "0.103.2",
22
- "@effectstream/event-server": "0.103.2",
23
- "@effectstream/log": "0.103.2",
24
- "@effectstream/sm": "0.103.2",
25
- "@effectstream/sync": "0.103.2",
26
- "@effectstream/utils": "0.103.2",
16
+ "@effectstream/concise": "0.104.0",
17
+ "@effectstream/config": "0.104.0",
18
+ "@effectstream/coroutine": "0.104.0",
19
+ "@effectstream/crypto": "0.104.0",
20
+ "@effectstream/db": "0.104.0",
21
+ "@effectstream/event-client": "0.104.0",
22
+ "@effectstream/event-server": "0.104.0",
23
+ "@effectstream/log": "0.104.0",
24
+ "@effectstream/sm": "0.104.0",
25
+ "@effectstream/sync": "0.104.0",
26
+ "@effectstream/utils": "0.104.0",
27
27
  "@fastify/cors": "^11.0.1",
28
28
  "@metamask/json-rpc-engine": "^10.0.3",
29
29
  "pg": "8.21.0",
@@ -5,7 +5,7 @@ import { finalizedStreamStatus } from "./stream-status.ts";
5
5
  import { buildHealthReport, healthHttpStatus } from "./health.ts";
6
6
  import type { Pool } from "pg";
7
7
  import cors from "@fastify/cors";
8
- import { run, until } from "effection";
8
+ import { ensure, run, suspend, until } from "effection";
9
9
  import {
10
10
  acquireDBMutex,
11
11
  getAllAddresses,
@@ -1039,16 +1039,14 @@ export const startHttpServer = function* (
1039
1039
  );
1040
1040
  });
1041
1041
 
1042
- // Start the server
1043
- server.listen(
1044
- { port: ENV.EFFECTSTREAM_API_PORT, host: "0.0.0.0" },
1045
- (err: Error | null, address: string) => {
1046
- if (err) {
1047
- console.error("err", err);
1048
- }
1049
- console.log(`Paima Engine HTTP server running on ${address}`);
1050
- },
1042
+ yield* ensure(function* () {
1043
+ if (server.server.listening) yield* until(server.close());
1044
+ });
1045
+ const address = yield* until(
1046
+ server.listen({ port: ENV.EFFECTSTREAM_API_PORT, host: "0.0.0.0" }),
1051
1047
  );
1048
+ console.log(`Paima Engine HTTP server running on ${address}`);
1049
+ yield* suspend();
1052
1050
  };
1053
1051
 
1054
1052
  export function clearBigInts<T>(value: T): T {
package/src/coalesce.ts CHANGED
@@ -20,7 +20,7 @@ import { Buffer } from "node:buffer";
20
20
  import { ComponentNames, log, SeverityNumber } from "@effectstream/log";
21
21
  import { generateEffectstreamBlockHash, Prando } from "@effectstream/crypto";
22
22
  import type { EffectstreamBlockHash } from "@effectstream/utils";
23
- import type { DBMigrations } from "@effectstream/runtime";
23
+ import type { DBMigrations } from "./types.ts";
24
24
  import { mergeCoalescingBoundaries } from "@effectstream/sync";
25
25
 
26
26
  /** Scheduled-input boundaries sampled once at run start (stable until the next non-empty block). */
package/src/main.ts CHANGED
@@ -23,6 +23,8 @@ import {
23
23
  import { startMerge, startSync } from "@effectstream/sync";
24
24
  import { ComponentNames, log, SeverityNumber } from "@effectstream/log";
25
25
  import {
26
+ call,
27
+ ensure,
26
28
  type Operation,
27
29
  sleep,
28
30
  spawn,
@@ -68,6 +70,9 @@ export function* start(config: StartConfig): Operation<void> {
68
70
  const { syncInfo } = config;
69
71
 
70
72
  const dbConn = getConnection();
73
+ yield* ensure(function* () {
74
+ yield* call(() => dbConn.end());
75
+ });
71
76
 
72
77
  const syncProtocols = yield* startup(dbConn as any, // Client,
73
78
  syncInfo, config);
@@ -176,6 +181,7 @@ export function* start(config: StartConfig): Operation<void> {
176
181
  endpoint.blockNumber,
177
182
  endpoint.timestamp,
178
183
  getRangesForSyncProtocols(endpoint),
184
+ config.events !== false,
179
185
  );
180
186
  log.local(
181
187
  ComponentNames.EFFECTSTREAM_SYNC,
@@ -224,8 +230,9 @@ export function* start(config: StartConfig): Operation<void> {
224
230
  value.blockNumber,
225
231
  value.timestamp,
226
232
  contentBlocksForProtocol,
233
+ config.events !== false,
227
234
  );
228
- for (const { event, payload } of blockAppEvents) {
235
+ for (const { event, payload } of config.events === false ? [] : blockAppEvents) {
229
236
  EventManager.Instance.sendMessage(event, payload as any).catch((err) => {
230
237
  log.local(
231
238
  ComponentNames.EFFECTSTREAM_RUNTIME,
@@ -279,7 +286,9 @@ function emitLatestBlocks(
279
286
  rollUpBlockHeight: number,
280
287
  rollUpBlockTimestamp: number,
281
288
  syncChains: Record<string, [number, number]>,
289
+ enabled = true,
282
290
  ): void {
291
+ if (!enabled) return;
283
292
  const logFailure = (topic: string) => (err: unknown) =>
284
293
  log.local(
285
294
  ComponentNames.EFFECTSTREAM_RUNTIME,
@@ -407,4 +416,4 @@ const processPrimitives = (
407
416
  }
408
417
  // Update the primitive with the final configuration
409
418
  primitives[primitiveIndex].primitive = p.getConfig();
410
- }
419
+ }
package/src/types.ts CHANGED
@@ -59,6 +59,8 @@ export type StartConfig = {
59
59
  apiRouter?: StartConfigApiRouter;
60
60
  grammar?: GrammarDefinition;
61
61
  userDefinedPrimitives?: Record<string, PrimitiveConstructor<any>>;
62
+ /** Publish MQTT events. Defaults to true; small read-only nodes may disable it. */
63
+ events?: boolean;
62
64
  /**
63
65
  * Automated database snapshot configuration via `pg_dump`.
64
66
  * An empty object `{}` enables snapshots with all defaults.
@@ -12,7 +12,7 @@ import {
12
12
  getMigrationsForBlockHeight,
13
13
  insertPaimaEngineVersion,
14
14
  } from "@effectstream/db";
15
- import type { DBMigrations, VERSION } from "@effectstream/runtime";
15
+ import type { DBMigrations, VERSION } from "./types.ts";
16
16
 
17
17
  type SystemMigration = {
18
18
  version: VERSION;