History

refactor(cloud): fold execution usage tracking into AutumnService

`makeTrackExecutionUsage` lived in its own `services/autumn-tracker.ts` only to dodge the `api/layers.ts` → `@tanstack/react-start` import cycle that breaks vitest-pool-workers. It baked fire-and-forget semantics + error logging into the function shape — callers got back a `(id) => void` and couldn't compose or test the billing call. Moves the tracker onto the service itself as `AutumnService.trackExecution` (Effect shape, error channel `never`), matching the existing `use` method pattern. Callers now `Effect.runFork(autumn.trackExecution(id))` at the single boundary in `execution-stack.ts`, which is honest about the fire-and-forget choice happening at that layer — not in the service. - `services/autumn.ts`: adds `trackExecution` to `IAutumnService`. Errors are caught and logged; the returned Effect never fails. Wrapped in an `autumn.trackExecution` span so traces pick it up the same way the existing `use` calls do. - `services/execution-stack.ts`: inlines the `Effect.runFork` at the sole caller; drops the `autumn-tracker` import. - `api/autumn.ts`: drops the re-export that pointed at the old file. - Deletes `services/autumn-tracker.ts`.

Rhys Sullivan committed 7 months ago

Commit af8a33a1 parent a6b58b74 files · +27 −49Browse files

Showing the changes to apps/cloud/src/api (1 of 4 files). Show all

Unified · Split

apps/cloud/src/api/autumn.ts+0−6
@@ -8,12 +8,6 @@ import { AutumnService } from "../services/autumn"; · 7 unmodified lines
88 import { HttpResponseError, isServerError, toErrorServerResponse } from "./error-response";
99 import { SharedServices } from "./layers";
1010
11−// Re-export so existing callers don't have to change their import path.
12−// The actual implementation moved to `services/autumn-tracker.ts` to break
13−// a DO → api/* → tanstack-start import cycle that crashed module load
14−// under vitest-pool-workers.
15−export { makeTrackExecutionUsage } from "../services/autumn-tracker";
16−
1711 const handleAutumnRequestEffect = Effect.gen(function* () {
1812 const request = yield* HttpServerRequest.HttpServerRequest;
1913 const webRequest = yield* Effect.mapError(

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t