@entifix/business 0.17.0 → 0.18.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.
@@ -47,6 +47,19 @@ export interface ShutdownRegistry {
47
47
  * it consults any probe: nothing is failing, the process is leaving.
48
48
  */
49
49
  readonly terminating: Effect.Effect<boolean>;
50
+ /**
51
+ * Completes the moment this process begins terminating — on the signal,
52
+ * **before** the server closes — and never fails.
53
+ *
54
+ * For a connection that only ends when told to: a server-sent stream. The
55
+ * server's close waits for every open response, and a stream is one that
56
+ * never finishes by itself, so a stream drained in a hook or a finalizer —
57
+ * both run after that close — was held open until the server gave up on it,
58
+ * twenty seconds on, and then cut without the `retry:` that spreads its
59
+ * reconnect (#492). Awaiting this instead ends it first, and the close is
60
+ * immediate.
61
+ */
62
+ readonly whenTerminating: Effect.Effect<void>;
50
63
  /**
51
64
  * Run every hook, phase by phase, in registration order. Never fails.
52
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"shutdown-registry.d.ts","sourceRoot":"","sources":["../../src/shutdown/shutdown-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,mCAAoC,CAAC;AAEjE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACnC;AAaD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE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M,CAAC,IAAI,CAAC,CAAC;;AAEzB,qBAAa,mBAAoB,SAAQ,wBAGf;CAAG;AAyB7B;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAQ,mBAAuC,KAC9C;IACD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;CA4CnB,CAAC"}
@@ -49,13 +49,22 @@ export class ShutdownRegistryTag extends Context.Service()('ShutdownRegistryTag'
49
49
  */ export const makeShutdownRegistry = (report = ()=>Effect.void)=>{
50
50
  const hooks = [];
51
51
  let terminating = false;
52
+ const waiting = [];
53
+ const signalled = new Promise((resolve)=>{
54
+ waiting.push(resolve);
55
+ });
56
+ const terminate = ()=>{
57
+ terminating = true;
58
+ for (const wake of waiting)wake();
59
+ };
52
60
  const registry = {
53
61
  register: (hook)=>Effect.sync(()=>{
54
62
  hooks.push(hook);
55
63
  }),
56
64
  terminating: Effect.sync(()=>terminating),
65
+ whenTerminating: Effect.promise(()=>signalled),
57
66
  drain: Effect.gen(function*() {
58
- terminating = true;
67
+ terminate();
59
68
  yield* report({
60
69
  _tag: 'draining',
61
70
  hooks: hooks.length
@@ -75,9 +84,7 @@ export class ShutdownRegistryTag extends Context.Service()('ShutdownRegistryTag'
75
84
  };
76
85
  return {
77
86
  registry,
78
- begin: ()=>{
79
- terminating = true;
80
- }
87
+ begin: terminate
81
88
  };
82
89
  };
83
90
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shutdown/shutdown-registry.ts"],"sourcesContent":["import { Cause, Context, Effect } from 'effect';\n\n/**\n * The order a shutdown runs in.\n *\n * **`stop-intake`** stops the process taking new work — cancelling the bus's\n * consumers, interrupting a polling daemon. **`flush`** carries out what is\n * already committed but not yet delivered: the outbox relay's final pass. The\n * two are separate phases rather than one list because they are ordered against\n * each other and not merely against the connections closing — flushing while\n * consumers are still folding events would race a drain against fresh work, and\n * the relay would go on finding entries the handlers keep writing.\n */\nexport const SHUTDOWN_PHASES = ['stop-intake', 'flush'] as const;\n\nexport type ShutdownPhase = (typeof SHUTDOWN_PHASES)[number];\n\n/**\n * One thing to do before this process's connections close.\n *\n * `run` is fully applied, exactly like `HealthProbe.check`: whoever\n * registers the hook has already closed over the connector, the fiber or the\n * store, so the drain can run every hook without knowing what any of them\n * touches.\n */\nexport interface ShutdownHook {\n /** Logged when the hook runs, and when it fails. Never rendered to a caller. */\n readonly name: string;\n readonly phase: ShutdownPhase;\n readonly run: Effect.Effect<void>;\n}\n\n/**\n * How long one hook may take before the drain moves on without it.\n *\n * Not belt-and-braces. Kubernetes sends SIGKILL at the end of\n * `terminationGracePeriodSeconds` whatever the process is doing, so an\n * unbounded hook does not buy time — it spends the budget of the hooks behind\n * it and then loses them entirely. A hook that cannot finish in time has\n * already failed; the difference is whether the *next* one gets to run.\n */\nconst HOOK_TIMEOUT = '10 seconds';\n\n/**\n * What a service does on its way out, registered by whoever opened the thing\n * that needs draining.\n *\n * A sibling of `HealthRegistry` and `WiringRegistry`, and for the same reason:\n * a `-service` that gains a bus gains its consumer drain by merging that\n * adapter's layer, and nothing in the service's own `main.ts` has to remember\n * to list it. A hand-written sequence per composition root drifts the first\n * time someone adds a dependency; this cannot, because the hook ships with the\n * client that needs it.\n */\nexport interface ShutdownRegistry {\n /** Add a hook. Called by an adapter layer as it constructs its client. */\n readonly register: (hook: ShutdownHook) => Effect.Effect<void>;\n /**\n * Whether this process has begun terminating.\n *\n * Read by `GET /api/health/ready`, which answers `503` from here **before**\n * it consults any probe: nothing is failing, the process is leaving.\n */\n readonly terminating: Effect.Effect<boolean>;\n /**\n * Run every hook, phase by phase, in registration order. Never fails.\n *\n * Called from a `Layer` finalizer, which is what orders it: the drain layer\n * is built after the composition root, so it is released before it, and the\n * connections a hook needs are still open while it runs.\n */\n readonly drain: Effect.Effect<void>;\n}\n\n/**\n * DI tag for the shutdown registry.\n *\n * In the contract layer beside `HealthRegistryTag` so an\n * `entifix-ts-*-client` package can register a hook without depending on a\n * shell.\n */\n/**\n * What a drain did, for the host to log\n * ([ADR 0013](../../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)):\n * the registry says it, the shell that made it decides how loud.\n */\nexport type ShutdownOutcome =\n | { readonly _tag: 'draining'; readonly hooks: number }\n | {\n readonly _tag: 'hookFailed';\n readonly hook: string;\n readonly phase: ShutdownPhase;\n /** `Cause.pretty`: a timeout and a failure stay distinguishable. */\n readonly cause: string;\n }\n | { readonly _tag: 'drained' };\n\n/** Where a drain reports what it did. */\nexport type ShutdownOutcomeSink = (\n outcome: ShutdownOutcome,\n) => Effect.Effect<void>;\n\nexport class ShutdownRegistryTag extends Context.Service<\n ShutdownRegistryTag,\n ShutdownRegistry\n>()('ShutdownRegistryTag') {}\n\n/**\n * Runs one hook and swallows whatever it does.\n *\n * A failure and a timeout are reported the same way on purpose: both mean this\n * hook did not do its job, both leave the ones behind it still worth running,\n * and neither is something a terminating process can act on. `Cause.pretty`\n * keeps them distinguishable for whoever reads the log the host writes.\n */\nconst runHook =\n (report: ShutdownOutcomeSink) =>\n (hook: ShutdownHook): Effect.Effect<void> =>\n hook.run.pipe(\n Effect.timeout(HOOK_TIMEOUT),\n Effect.catchCause(cause =>\n report({\n _tag: 'hookFailed',\n hook: hook.name,\n phase: hook.phase,\n cause: Cause.pretty(cause),\n }),\n ),\n );\n\n/**\n * Builds the registry and the synchronous latch that flips it.\n *\n * Two halves for two callers, the `makeAmqpConnector` shape: the\n * `registry` goes into the layer graph, while `begin` is called from a\n * `process.on('SIGTERM')` handler — outside Effect, in the same tick the\n * runtime starts interrupting — so `/api/health/ready` stops claiming to be\n * ready the instant the signal lands rather than whenever the finalizers get\n * around to running.\n */\nexport const makeShutdownRegistry = (\n report: ShutdownOutcomeSink = () => Effect.void,\n): {\n registry: ShutdownRegistry;\n begin: () => void;\n} => {\n const hooks: ShutdownHook[] = [];\n let terminating = false;\n\n const registry: ShutdownRegistry = {\n register: hook =>\n Effect.sync(() => {\n hooks.push(hook);\n }),\n\n terminating: Effect.sync(() => terminating),\n\n drain: Effect.gen(function* () {\n terminating = true;\n yield* report({ _tag: 'draining', hooks: hooks.length });\n for (const phase of SHUTDOWN_PHASES) {\n // Sequential, and in registration order: `stop-intake` before `flush`\n // is the whole contract, and within a phase a later hook may depend on\n // an earlier one having stopped.\n yield* Effect.forEach(\n hooks.filter(hook => hook.phase === phase),\n runHook(report),\n { discard: true },\n );\n }\n yield* report({ _tag: 'drained' });\n }),\n };\n\n return {\n registry,\n begin: () => {\n terminating = true;\n },\n };\n};\n"],"names":["Cause","Context","Effect","SHUTDOWN_PHASES","HOOK_TIMEOUT","ShutdownRegistryTag","Service","runHook","report","hook","run","pipe","timeout","catchCause","cause","_tag","name","phase","pretty","makeShutdownRegistry","void","hooks","terminating","registry","register","sync","push","drain","gen","length","forEach","filter","discard","begin"],"mappings":"AAAA,SAASA,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAEhD;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,kBAAkB;IAAC;IAAe;CAAQ,CAAU;AAmBjE;;;;;;;;CAQC,GACD,MAAMC,eAAe;AA6DrB,OAAO,MAAMC,4BAA4BJ,QAAQK,OAAO,GAGpD;AAAwB;AAE5B;;;;;;;CAOC,GACD,MAAMC,UACJ,CAACC,SACD,CAACC,OACCA,KAAKC,GAAG,CAACC,IAAI,CACXT,OAAOU,OAAO,CAACR,eACfF,OAAOW,UAAU,CAACC,CAAAA,QAChBN,OAAO;gBACLO,MAAM;gBACNN,MAAMA,KAAKO,IAAI;gBACfC,OAAOR,KAAKQ,KAAK;gBACjBH,OAAOd,MAAMkB,MAAM,CAACJ;YACtB;AAIR;;;;;;;;;CASC,GACD,OAAO,MAAMK,uBAAuB,CAClCX,SAA8B,IAAMN,OAAOkB,IAAI;IAK/C,MAAMC,QAAwB,EAAE;IAChC,IAAIC,cAAc;IAElB,MAAMC,WAA6B;QACjCC,UAAUf,CAAAA,OACRP,OAAOuB,IAAI,CAAC;gBACVJ,MAAMK,IAAI,CAACjB;YACb;QAEFa,aAAapB,OAAOuB,IAAI,CAAC,IAAMH;QAE/BK,OAAOzB,OAAO0B,GAAG,CAAC;YAChBN,cAAc;YACd,OAAOd,OAAO;gBAAEO,MAAM;gBAAYM,OAAOA,MAAMQ,MAAM;YAAC;YACtD,KAAK,MAAMZ,SAASd,gBAAiB;gBACnC,sEAAsE;gBACtE,uEAAuE;gBACvE,iCAAiC;gBACjC,OAAOD,OAAO4B,OAAO,CACnBT,MAAMU,MAAM,CAACtB,CAAAA,OAAQA,KAAKQ,KAAK,KAAKA,QACpCV,QAAQC,SACR;oBAAEwB,SAAS;gBAAK;YAEpB;YACA,OAAOxB,OAAO;gBAAEO,MAAM;YAAU;QAClC;IACF;IAEA,OAAO;QACLQ;QACAU,OAAO;YACLX,cAAc;QAChB;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/shutdown/shutdown-registry.ts"],"sourcesContent":["import { Cause, Context, Effect } from 'effect';\n\n/**\n * The order a shutdown runs in.\n *\n * **`stop-intake`** stops the process taking new work — cancelling the bus's\n * consumers, interrupting a polling daemon. **`flush`** carries out what is\n * already committed but not yet delivered: the outbox relay's final pass. The\n * two are separate phases rather than one list because they are ordered against\n * each other and not merely against the connections closing — flushing while\n * consumers are still folding events would race a drain against fresh work, and\n * the relay would go on finding entries the handlers keep writing.\n */\nexport const SHUTDOWN_PHASES = ['stop-intake', 'flush'] as const;\n\nexport type ShutdownPhase = (typeof SHUTDOWN_PHASES)[number];\n\n/**\n * One thing to do before this process's connections close.\n *\n * `run` is fully applied, exactly like `HealthProbe.check`: whoever\n * registers the hook has already closed over the connector, the fiber or the\n * store, so the drain can run every hook without knowing what any of them\n * touches.\n */\nexport interface ShutdownHook {\n /** Logged when the hook runs, and when it fails. Never rendered to a caller. */\n readonly name: string;\n readonly phase: ShutdownPhase;\n readonly run: Effect.Effect<void>;\n}\n\n/**\n * How long one hook may take before the drain moves on without it.\n *\n * Not belt-and-braces. Kubernetes sends SIGKILL at the end of\n * `terminationGracePeriodSeconds` whatever the process is doing, so an\n * unbounded hook does not buy time — it spends the budget of the hooks behind\n * it and then loses them entirely. A hook that cannot finish in time has\n * already failed; the difference is whether the *next* one gets to run.\n */\nconst HOOK_TIMEOUT = '10 seconds';\n\n/**\n * What a service does on its way out, registered by whoever opened the thing\n * that needs draining.\n *\n * A sibling of `HealthRegistry` and `WiringRegistry`, and for the same reason:\n * a `-service` that gains a bus gains its consumer drain by merging that\n * adapter's layer, and nothing in the service's own `main.ts` has to remember\n * to list it. A hand-written sequence per composition root drifts the first\n * time someone adds a dependency; this cannot, because the hook ships with the\n * client that needs it.\n */\nexport interface ShutdownRegistry {\n /** Add a hook. Called by an adapter layer as it constructs its client. */\n readonly register: (hook: ShutdownHook) => Effect.Effect<void>;\n /**\n * Whether this process has begun terminating.\n *\n * Read by `GET /api/health/ready`, which answers `503` from here **before**\n * it consults any probe: nothing is failing, the process is leaving.\n */\n readonly terminating: Effect.Effect<boolean>;\n /**\n * Completes the moment this process begins terminating — on the signal,\n * **before** the server closes — and never fails.\n *\n * For a connection that only ends when told to: a server-sent stream. The\n * server's close waits for every open response, and a stream is one that\n * never finishes by itself, so a stream drained in a hook or a finalizer —\n * both run after that close — was held open until the server gave up on it,\n * twenty seconds on, and then cut without the `retry:` that spreads its\n * reconnect (#492). Awaiting this instead ends it first, and the close is\n * immediate.\n */\n readonly whenTerminating: Effect.Effect<void>;\n /**\n * Run every hook, phase by phase, in registration order. Never fails.\n *\n * Called from a `Layer` finalizer, which is what orders it: the drain layer\n * is built after the composition root, so it is released before it, and the\n * connections a hook needs are still open while it runs.\n */\n readonly drain: Effect.Effect<void>;\n}\n\n/**\n * DI tag for the shutdown registry.\n *\n * In the contract layer beside `HealthRegistryTag` so an\n * `entifix-ts-*-client` package can register a hook without depending on a\n * shell.\n */\n/**\n * What a drain did, for the host to log\n * ([ADR 0013](../../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)):\n * the registry says it, the shell that made it decides how loud.\n */\nexport type ShutdownOutcome =\n | { readonly _tag: 'draining'; readonly hooks: number }\n | {\n readonly _tag: 'hookFailed';\n readonly hook: string;\n readonly phase: ShutdownPhase;\n /** `Cause.pretty`: a timeout and a failure stay distinguishable. */\n readonly cause: string;\n }\n | { readonly _tag: 'drained' };\n\n/** Where a drain reports what it did. */\nexport type ShutdownOutcomeSink = (\n outcome: ShutdownOutcome,\n) => Effect.Effect<void>;\n\nexport class ShutdownRegistryTag extends Context.Service<\n ShutdownRegistryTag,\n ShutdownRegistry\n>()('ShutdownRegistryTag') {}\n\n/**\n * Runs one hook and swallows whatever it does.\n *\n * A failure and a timeout are reported the same way on purpose: both mean this\n * hook did not do its job, both leave the ones behind it still worth running,\n * and neither is something a terminating process can act on. `Cause.pretty`\n * keeps them distinguishable for whoever reads the log the host writes.\n */\nconst runHook =\n (report: ShutdownOutcomeSink) =>\n (hook: ShutdownHook): Effect.Effect<void> =>\n hook.run.pipe(\n Effect.timeout(HOOK_TIMEOUT),\n Effect.catchCause(cause =>\n report({\n _tag: 'hookFailed',\n hook: hook.name,\n phase: hook.phase,\n cause: Cause.pretty(cause),\n }),\n ),\n );\n\n/**\n * Builds the registry and the synchronous latch that flips it.\n *\n * Two halves for two callers, the `makeAmqpConnector` shape: the\n * `registry` goes into the layer graph, while `begin` is called from a\n * `process.on('SIGTERM')` handler — outside Effect, in the same tick the\n * runtime starts interrupting — so `/api/health/ready` stops claiming to be\n * ready the instant the signal lands rather than whenever the finalizers get\n * around to running.\n */\nexport const makeShutdownRegistry = (\n report: ShutdownOutcomeSink = () => Effect.void,\n): {\n registry: ShutdownRegistry;\n begin: () => void;\n} => {\n const hooks: ShutdownHook[] = [];\n let terminating = false;\n const waiting: (() => void)[] = [];\n const signalled = new Promise<void>(resolve => {\n waiting.push(resolve);\n });\n const terminate = () => {\n terminating = true;\n for (const wake of waiting) wake();\n };\n\n const registry: ShutdownRegistry = {\n register: hook =>\n Effect.sync(() => {\n hooks.push(hook);\n }),\n\n terminating: Effect.sync(() => terminating),\n\n whenTerminating: Effect.promise(() => signalled),\n\n drain: Effect.gen(function* () {\n terminate();\n yield* report({ _tag: 'draining', hooks: hooks.length });\n for (const phase of SHUTDOWN_PHASES) {\n // Sequential, and in registration order: `stop-intake` before `flush`\n // is the whole contract, and within a phase a later hook may depend on\n // an earlier one having stopped.\n yield* Effect.forEach(\n hooks.filter(hook => hook.phase === phase),\n runHook(report),\n { discard: true },\n );\n }\n yield* report({ _tag: 'drained' });\n }),\n };\n\n return {\n registry,\n begin: terminate,\n };\n};\n"],"names":["Cause","Context","Effect","SHUTDOWN_PHASES","HOOK_TIMEOUT","ShutdownRegistryTag","Service","runHook","report","hook","run","pipe","timeout","catchCause","cause","_tag","name","phase","pretty","makeShutdownRegistry","void","hooks","terminating","waiting","signalled","Promise","resolve","push","terminate","wake","registry","register","sync","whenTerminating","promise","drain","gen","length","forEach","filter","discard","begin"],"mappings":"AAAA,SAASA,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAEhD;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,kBAAkB;IAAC;IAAe;CAAQ,CAAU;AAmBjE;;;;;;;;CAQC,GACD,MAAMC,eAAe;AA0ErB,OAAO,MAAMC,4BAA4BJ,QAAQK,OAAO,GAGpD;AAAwB;AAE5B;;;;;;;CAOC,GACD,MAAMC,UACJ,CAACC,SACD,CAACC,OACCA,KAAKC,GAAG,CAACC,IAAI,CACXT,OAAOU,OAAO,CAACR,eACfF,OAAOW,UAAU,CAACC,CAAAA,QAChBN,OAAO;gBACLO,MAAM;gBACNN,MAAMA,KAAKO,IAAI;gBACfC,OAAOR,KAAKQ,KAAK;gBACjBH,OAAOd,MAAMkB,MAAM,CAACJ;YACtB;AAIR;;;;;;;;;CASC,GACD,OAAO,MAAMK,uBAAuB,CAClCX,SAA8B,IAAMN,OAAOkB,IAAI;IAK/C,MAAMC,QAAwB,EAAE;IAChC,IAAIC,cAAc;IAClB,MAAMC,UAA0B,EAAE;IAClC,MAAMC,YAAY,IAAIC,QAAcC,CAAAA;QAClCH,QAAQI,IAAI,CAACD;IACf;IACA,MAAME,YAAY;QAChBN,cAAc;QACd,KAAK,MAAMO,QAAQN,QAASM;IAC9B;IAEA,MAAMC,WAA6B;QACjCC,UAAUtB,CAAAA,OACRP,OAAO8B,IAAI,CAAC;gBACVX,MAAMM,IAAI,CAAClB;YACb;QAEFa,aAAapB,OAAO8B,IAAI,CAAC,IAAMV;QAE/BW,iBAAiB/B,OAAOgC,OAAO,CAAC,IAAMV;QAEtCW,OAAOjC,OAAOkC,GAAG,CAAC;YAChBR;YACA,OAAOpB,OAAO;gBAAEO,MAAM;gBAAYM,OAAOA,MAAMgB,MAAM;YAAC;YACtD,KAAK,MAAMpB,SAASd,gBAAiB;gBACnC,sEAAsE;gBACtE,uEAAuE;gBACvE,iCAAiC;gBACjC,OAAOD,OAAOoC,OAAO,CACnBjB,MAAMkB,MAAM,CAAC9B,CAAAA,OAAQA,KAAKQ,KAAK,KAAKA,QACpCV,QAAQC,SACR;oBAAEgC,SAAS;gBAAK;YAEpB;YACA,OAAOhC,OAAO;gBAAEO,MAAM;YAAU;QAClC;IACF;IAEA,OAAO;QACLe;QACAW,OAAOb;IACT;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/business",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "The ports every adapter implements — repository, session, token, health — and the generic get, load, save and delete use-cases.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@swc/helpers": "0.5.23",
69
- "@entifix/core": "0.17.0"
69
+ "@entifix/core": "0.18.0"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "effect": "^4.0.7"