Skip to content

[ADDED] Error() method to KeyLister and KeyWatcher interfaces #1889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025

Conversation

piotrpio
Copy link
Collaborator

@piotrpio piotrpio commented Jun 25, 2025

Added Error() method to KeyLister and KeyWatcher in legacy KV API. This allows detection of timeout when waiting for initial values in watchers.

Signed-off-by: Piotr Piotrowski piotr@synadia.com

…rfaces

The new Error() method returns <-chan error, enabling concurrent error
handling with select statements. This allows immediate detection of
timeout errors during key listing/watching operations.

Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
@piotrpio piotrpio changed the title [ADDED] Channel-based Error() method to KeyLister and KeyWatcher interfaces [ADDED] Error() method to KeyLister and KeyWatcher interfaces Jun 25, 2025
@coveralls
Copy link

coveralls commented Jun 25, 2025

Coverage Status

coverage: 84.788% (+0.1%) from 84.668%
when pulling 4bcb61c on add-kv-error-channels
into 3146d56 on main.

@Jarema Jarema requested a review from Copilot June 26, 2025 08:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds an Error() channel to the legacy KV interfaces so callers can detect timeouts when waiting for initial values.

  • Extended KeyWatcher and KeyLister interfaces with an Error() method.
  • Implemented errCh in the watcher and keyLister structs, sending ErrKeyWatcherTimeout on timeout and closing the channel on completion.
  • Added tests to validate channel-based error handling in both watch and list use cases.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
kv.go Defined Error() on KeyWatcher/KeyLister, introduced errCh and timeout error handling.
test/kv_test.go New test cases for select‐based and post‐completion error channel patterns.
Comments suppressed due to low confidence (1)

test/kv_test.go:947

  • [nitpick] This select loop has no timeout branch and could hang indefinitely if neither channel produces events. Add a case <-time.After(...) to fail fast on missing signals.
			select {

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@piotrpio piotrpio marked this pull request as ready for review June 27, 2025 09:51
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@piotrpio piotrpio merged commit b0b229c into main Jun 30, 2025
7 checks passed
@piotrpio piotrpio deleted the add-kv-error-channels branch June 30, 2025 10:04
@piotrpio piotrpio mentioned this pull request Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants