feat(appkit-ui): internal usePoll scheduler hook (poll 2/4) - #585
Draft
atilafassina wants to merge 1 commit into
Draft
atilafassina wants to merge 1 commit into
atilafassina wants to merge 1 commit into
Conversation
Transport-agnostic polling scheduler: usePoll(runOnce, options) drives an
async run-once action and reports lifecycle + telemetry (attempts, errors,
skipped, consecutiveErrors, lastLatencyMs, latency:{p50,p95}) with controls
(pause/resume/restart/refetch). Owns immediate-first tick, interval cadence,
in-flight skip guard, exponential backoff (1→2→4→8s capped, ticking-but-
skipping until deadline), and optional maxConsecutiveErrors pause. Knows
nothing of analytics/SSE/cursors. Internal — not exported from any barrel;
option/result types kept file-local so it lands dormant without tripping
knip. Wired behind useAnalyticsQuery({ poll }) in phase 3.
Tested with Vitest fake timers via vi.advanceTimersByTimeAsync inside
async act() (no waitFor under fake timers).
xavier loop: iteration 3 (phase 2/4)
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Atila Fassina <atila@fassina.eu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR 2 of 4 — analytics query polling.
Base:
poll-1-refetch(PR 1). Merge after PR 1.What
Add
usePoll(runOnce, options)— a transport-agnostic polling scheduler hook. Knows nothing about analytics/SSE/cursors.1→2→4→8scapped, ticking-but-skipping until deadline); optionalmaxConsecutiveErrorspause.pause/resume/restart/refetch. Telemetry:attempts, errors, skipped, consecutiveErrors, lastLatencyMs, latency:{p50,p95}.Dormant
Internal only — not exported from any barrel; option/result types kept file-local so it lands without tripping
knip.Stack
usePollscheduleruseAnalyticsQuery({ poll })binding + public typesTests
13 Vitest fake-timer tests (via
vi.advanceTimersByTimeAsyncinside asyncact()); full suite green.This pull request and its description were written by Isaac.