feat(client): add context.Context support for cancellation and timeout#118
Merged
xia0pin9 merged 3 commits intopinterest:masterfrom Jan 14, 2026
Merged
Conversation
csstaub
approved these changes
Jan 12, 2026
This commit adds context.Context support throughout the knox client to enable proper cancellation and timeout handling for long-running operations. Changes: - Add context.Context parameter to cache and network key retrieval methods - New methods: CacheGetKeyWithContext(), NetworkGetKeyWithContext(), getHTTPDataWithContext() - Add context cancellation checks before expensive operations: * Before file I/O operations * Before JSON unmarshaling * Before each auth handler attempt * Before each retry attempt * Before backoff sleep - Existing methods now delegate to *WithContext() variants with context.Background() for backward compatibility - Fix bug in fileClient.setValues() where active keys were incorrectly appended instead of assigned to pre-allocated slice indices - Standardize error logging (Knox→knox, %s→%w, .Error()→err) The context support allows callers to: - Set timeouts for key retrieval operations - Cancel in-flight requests when they're no longer needed - Properly handle deadline exceeded scenarios All existing APIs maintain backward compatibility by using context.Background() internally.
6c8c291 to
b88a91c
Compare
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.
This commit adds context.Context support throughout the knox client to enable proper cancellation and timeout handling for long-running operations.
Changes:
The context support allows callers to:
All existing APIs maintain backward compatibility by using context.Background() internally.