meilisearch / meilisearch-go

Golang wrapper for the Meilisearch API
https://www.meilisearch.com
MIT License
481 stars 81 forks source link

Make `client.WaitForTask` use select and channels for polling #495

Closed tadejsv closed 8 months ago

tadejsv commented 8 months ago

Pull Request

Related issue

No issue, all changes described in this PR

What does this PR do?

Using the select statement with channels is considered more idiomatic Go than using time.Sleep, and also enables the waiting to be interrupted by context cancellation in the middle of a polling interval.

Performance-wise both options are similar (see here).

PR checklist

Please check if your PR fulfills the following requirements:

Thank you so much for contributing to Meilisearch!

codecov[bot] commented 8 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (5758b3a) 80.85% compared to head (360681d) 80.86%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #495 +/- ## ========================================== + Coverage 80.85% 80.86% +0.01% ========================================== Files 10 10 Lines 1901 1902 +1 ========================================== + Hits 1537 1538 +1 Misses 252 252 Partials 112 112 ``` | [Files](https://app.codecov.io/gh/meilisearch/meilisearch-go/pull/495?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meilisearch) | Coverage Δ | | |---|---|---| | [client.go](https://app.codecov.io/gh/meilisearch/meilisearch-go/pull/495?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meilisearch#diff-Y2xpZW50Lmdv) | `83.17% <75.00%> (+0.04%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

meili-bors[bot] commented 8 months ago

Build succeeded: