History

Probe connection health through a per-connection atom (#2071)

* e2e: reproduce health-probe churn on the integrations list Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Probe connection health through a per-connection atom Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * e2e: bound the churn scenario to its own connections Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> ---------

Rhys Sullivan committed 1 month agomain

Commit 09c19e41 parent 1aa6fd93 files · +368 −7Browse files

Showing the changes to packages/react/src/api (1 of 3 files). Show all

Unified · Split

packages/react/src/api/atoms.tsx+32−0
@@ -17,6 +17,7 @@ import { · 16 unmodified lines
17} from "@executor-js/sdk/shared";17} from "@executor-js/sdk/shared";
18import * as Atom from "effect/unstable/reactivity/Atom";18import * as Atom from "effect/unstable/reactivity/Atom";
19import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";19import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
20import * as Reactivity from "effect/unstable/reactivity/Reactivity";
20import * as Effect from "effect/Effect";21import * as Effect from "effect/Effect";
21 22
22import { ExecutorApiClient } from "./client";23import { ExecutorApiClient } from "./client";
@@ -198,6 +199,37 @@ export const refreshConnection = ExecutorApiClient.mutation("connections", "refr · 175 unmodified lines
198 * cache on every load). */199 * cache on every load). */
199export const checkConnectionHealth = ExecutorApiClient.mutation("connections", "checkHealth");200export const checkConnectionHealth = ExecutorApiClient.mutation("connections", "checkHealth");
200 201
202export interface CheckConnectionHealthArgs {
203 readonly params: {
204 readonly owner: Owner;
205 readonly integration: IntegrationSlug;
206 readonly name: ConnectionName;
207 };
208 readonly query: { readonly ifStaleMs?: number };
209 readonly reactivityKeys?: ReadonlyArray<unknown>;
210}
211
212/** The AUTOMATIC health probe, one atom PER CONNECTION.
213 *
214 * `checkConnectionHealth` above is one shared mutation atom. Awaiting it
215 * (`useAtomSet(..., { mode: "promiseExit" })`) resolves with the atom's next
216 * settled result, whichever call produced it, and a new call interrupts the
217 * one in flight. A surface that probes every row of a list in one pass
218 * therefore cancels all but the last probe and hands every row the LAST
219 * row's verdict. Each row then reads a foreign verdict as a change to its own
220 * connection, refreshes the connections cache, and re-probes: the probe storm
221 * the automatic path was built to avoid. Keying the atom by connection address
222 * gives every probe its own fiber and its own result. */
223export const checkConnectionHealthFor = Atom.family((address: ConnectionAddress) =>
224 ExecutorApiClient.runtime.fn<CheckConnectionHealthArgs>()((args) => {
225 const probe = Effect.gen(function* () {
226 const client = yield* ExecutorApiClient;
227 return yield* client.connections.checkHealth({ params: args.params, query: args.query });
228 }).pipe(Effect.withSpan("connection.health.probe", { attributes: { address } }));
229 return args.reactivityKeys ? Reactivity.mutation(probe, args.reactivityKeys) : probe;
230 }),
231);
232
201/** Validate an IN-FLIGHT credential without saving it (the key-first connect233/** Validate an IN-FLIGHT credential without saving it (the key-first connect
202 * flow). Returns the probe result the UI derives a connection name from. */234 * flow). Returns the probe result the UI derives a connection name from. */
203export const validateConnection = ExecutorApiClient.mutation("connections", "validate");235export const validateConnection = ExecutorApiClient.mutation("connections", "validate");

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