diff --git a/.changeset/cyan-moles-grow.md b/.changeset/cyan-moles-grow.md new file mode 100644 index 000000000..791044751 --- /dev/null +++ b/.changeset/cyan-moles-grow.md @@ -0,0 +1,5 @@ +--- +"@effect-app/infra-adapters": minor +--- + +drop runMain (use platform-node runMain) diff --git a/packages/infra-adapters/_src/_global.ts b/packages/infra-adapters/_src/_global.ts index f7ccad4fd..144f5dfc7 100644 --- a/packages/infra-adapters/_src/_global.ts +++ b/packages/infra-adapters/_src/_global.ts @@ -7,8 +7,3 @@ import "@effect-app/schema/_global" * @tsplus global */ import { Logger } from "effect/Logger" - -/** - * @tsplus global - */ -import {} from "@effect-app/infra-adapters/runMain" diff --git a/packages/infra-adapters/_src/runMain.ts b/packages/infra-adapters/_src/runMain.ts deleted file mode 100644 index 5eabe52f9..000000000 --- a/packages/infra-adapters/_src/runMain.ts +++ /dev/null @@ -1,64 +0,0 @@ -import type { FiberId } from "effect/FiberId" - -export function defaultTeardown( - status: number, - id: FiberId, - onExit: (status: number) => void -) { - Fiber - .roots - .flatMap((_) => _.interruptAllAs(id)) - .runCallback(() => { - setTimeout(() => { - if (Fiber.unsafeRoots().length === 0) { - onExit(status) - } else { - defaultTeardown(status, id, onExit) - } - }, 0) - }) -} - -/** - * A dumbed down version of effect-ts/node's runtime, in preparation of new effect-ts - * @tsplus fluent effect/io/Effect runMain - */ -export function runMain(eff: Effect) { - const onExit = (s: number) => { - process.exit(s) - } - - Fiber - .fromEffect(eff) - .map((context) => { - context - .await - .flatMap((exit) => - Effect.gen(function*($) { - if (exit.isFailure()) { - if (exit.cause.isInterruptedOnly()) { - yield* $(Effect.logWarning("Main process Interrupted")) - defaultTeardown(0, context.id(), onExit) - return - } else { - yield* $(Effect.logError("Main process Error", exit.cause)) - defaultTeardown(1, context.id(), onExit) - return - } - } else { - defaultTeardown(0, context.id(), onExit) - } - }) - ) - .runCallback() - - function handler() { - process.removeListener("SIGTERM", handler) - process.removeListener("SIGINT", handler) - context.interruptAsFork(context.id()).runCallback() - } - process.once("SIGTERM", handler) - process.once("SIGINT", handler) - }) - .runCallback() -} diff --git a/packages/infra-adapters/package.json b/packages/infra-adapters/package.json index 74c2b4dfb..eae932025 100644 --- a/packages/infra-adapters/package.json +++ b/packages/infra-adapters/package.json @@ -282,16 +282,6 @@ "types": "./dist/redis-client.d.ts", "default": "./_cjs/redis-client.cjs" } - }, - "./runMain": { - "import": { - "types": "./dist/runMain.d.ts", - "default": "./dist/runMain.js" - }, - "require": { - "types": "./dist/runMain.d.ts", - "default": "./_cjs/runMain.cjs" - } } }, "sideEffects": false,