-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Improve client initialization handling. #27
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
Conversation
| return; | ||
| } | ||
|
|
||
| boolean initialized = client.getDataSourceStatusProvider().waitFor(DataSourceStatusProvider.State.VALID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were a couple problems here. The waitFor method just not handle FOREVER, and so was doing some invalid math.
Also it really needs to check for either OFF or VALID, which this API doesn't really have an ergonomic way to do.
So instead we use synchronized blocks with wait. Whenever the state changes the checking code wakes up and checks if initialization is complete.
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| class DelayedDataSource implements DataSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data source which allow initialization to complete or fail after some duration. Allowing us to test the path where the client is not immediately initialized (as it is in offline mode).
| handleDataSourceStatus(res); | ||
| }); | ||
|
|
||
| handleDataSourceStatus(client.getDataSourceStatusProvider().getStatus()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually fetch data source status in case it updated before the callback was registered.
🤖 I have created a release *beep* *boop* --- ## [0.2.3](0.2.2...0.2.3) (2024-06-06) ### Bug Fixes * Improve client initialization handling. ([#27](#27)) ([cf0ed18](cf0ed18)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
No description provided.