Add context-aware requests and configurable timeout - #27
Merged
Conversation
Thread context.Context through the Metabase client and CLI so HTTP requests can be cancelled and time-bounded consistently. - Client request methods accept a context and build requests with http.NewRequestWithContext; report clear timeout/cancellation errors. - Root context is cancelled on SIGINT/SIGTERM so commands abort on Ctrl+C. - New --timeout flag (default 30s, 0 disables) bounds each command's API requests. - Classify timeout and cancellation errors for --error-format json. Closes #11
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.
Summary
Closes #11.
Threads
context.Contextthrough the Metabase client and CLI so HTTPrequests can be cancelled and time-bounded consistently, as requested in
issue #11.
http.NewRequestWithContext;Doreports clearrequest timed out/request cancelederrors while still wrappingcontext.DeadlineExceededand
context.Canceledfor programmatic detection.signal.NotifyContext,so commands abort cleanly on Ctrl+C.
--timeoutflag (duration, default30s,0disables) bounds eachcommand's API requests, replacing the fixed
http.Clienttimeout.TIMEOUT_ERROR/CANCELED_ERRORfor--error-format json.Existing command output and PII redaction behavior are unchanged.
Changelog
## [Unreleased]inCHANGELOG.mdTest plan
make fmt,make vet,make test,make buildall pass.tests/request_context_test.gocovers Get/Post cancellation, Gettimeout, context propagation through a high-level client method, and an
end-to-end
--timeoutCLI test; error-classification tests cover the newerror types.
dashboard/query/search commands return expected output.
--timeout 1msproduces a structuredTIMEOUT_ERROR.SELECT pg_sleep(10)withrequest canceled: ... context canceledand a non-zero exit.