Skip to content
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

add StartContext, remove Stop #147

Merged
merged 1 commit into from
Dec 20, 2022
Merged

add StartContext, remove Stop #147

merged 1 commit into from
Dec 20, 2022

Conversation

tomwans
Copy link
Contributor

@tomwans tomwans commented Dec 20, 2022

This change removes the Stop() method from the previous change, and fixes the Start behavior to be backwards compatible.

The previous change changed the behavior of Start() to be non-blocking from blocking. This is a change in API that we should revert. Stop is also removed - even though this too is a breaking change this is not a 1.0 release and the release is short-lived as of right now.

This change introduces a new method, StartContext, which should achieve the goals from the last change, but retain backwards compatibility.

StartContext is a blocking call like Start is, but allows for a context to be passed in, thus allowing for cancellation.

danielmmetz
danielmmetz previously approved these changes Dec 20, 2022
Copy link
Contributor

@danielmmetz danielmmetz left a comment

Choose a reason for hiding this comment

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

Approving for now, but still thinking about alternative ways to validate what we want with a test.

stats.go Show resolved Hide resolved
stats_test.go Outdated
if realStore.stop != nil {
t.Errorf("expected stop channel to be nil")
}
realStore.wg.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a timeout? something like:

Suggested change
realStore.wg.Wait()
done := make(chan struct{})
go func() {
defer close(done)
realStore.wg.Wait()
}()
select {
case <-done:
case <-time.After(1 * time.Second):
t.Errorf("blocked for too long waiting for stopped store")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is already precedent on another test to just call Wait() and potentially hang forever, so going to be consistent.

This change removes the Stop() method from the previous change, and
fixes the Start behavior to be backwards compatible.

The previous change changed the behavior of Start() to be non-blocking
from blocking. This is a change in API that we should revert. Stop is
also removed - even though this too is a breaking change this is not a
1.0 release and the release is short-lived as of right now.

This change introduces a new method, StartContext, which should achieve
the goals from the last change, but retain backwards compatibility.

StartContext is a blocking call like Start is, but allows for a
context to be passed in, thus allowing for cancellation.
@tomwans tomwans merged commit 911c76a into master Dec 20, 2022
@tomwans tomwans deleted the startcontext branch December 20, 2022 22:46
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.

2 participants