-
Notifications
You must be signed in to change notification settings - Fork 92
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
Improve TaskClient
, BatchClient
and associated types
#1825
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1825 +/- ##
==========================================
- Coverage 99.17% 99.02% -0.15%
==========================================
Files 16 18 +2
Lines 1574 1435 -139
Branches 348 303 -45
==========================================
- Hits 1561 1421 -140
- Misses 13 14 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TaskClient
, BatchClient
, associated types, and settings typesTaskClient
, BatchClient
and associated types
…s into improve-task-batch
1848: Remove hint about bad Meilisearch version r=Strift a=flevi29 # Pull Request ## What does this PR do? - removes added warnings for potential bad Meilisearch version - there are many more places these should be added otherwise, but that would be a lot of trouble to maintain and counter productive, so let's instead remove the outliers - it would also make my life easier with the upcoming #1825 ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: F. Levi <[email protected]> Co-authored-by: Laurent Cazanove <[email protected]>
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.
Pull Request Overview
This PR reworks task and batch handling by removing redundant classes, renaming types to match API responses, and refactoring task waiting logic. Key changes include the removal of legacy task classes, an updated TaskClient using AbortController for timeouts, and revised type definitions across the codebase.
Reviewed Changes
Copilot reviewed 65 out of 65 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/types/types.ts | Removed redundant imports and adjusted type properties (e.g. Dates to strings) |
src/task.ts | Refactored TaskClient methods for waiting tasks and integrated AbortController for timeouts |
src/meilisearch.ts | Updated usage of TaskClient and BatchClient to reflect new type definitions and methods |
Other files (token, batch, errors, etc.) | Updated, migrated, or removed legacy types and classes to align with new API responses |
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.
LGTM 🙌
Awesome stuff, this will make the codebase much cleaner
Pull Request
What does this PR do?
Batch
,EnqueuedTask
andTask
*Object
equivalent objects, that come from the API responses, for the most part with the same exact properties and valuesDate
objects, but this functionality is also being removed, because:meilisearch
Rust source codeEnqueuedTaskObject
toEnqueuedTask
canceledBy
property as it doesn't existindexUid
property cannot beundefined
but can benull
BatchObject
toBatch
, adjust propertiesTaskObject
toTask
, adjust propertiesTask.details
had quite a few properties missing, likepagination
, now it's reusing theSettings
type, so we don't repeat ourselvesTaskClient
waitForTask
, now it usessetTimeout
for timeout instead of inaccurate expensive date calculationsEnqueuedTask
object as parameterwaitForTasks
can now accept an iterable or an asynchronous iterable instead of just an array as parameterwaitForTasksIter
, which is an asynchronous generator, that lazily awaits the tasksPromise<EnqueuedTask>
now instead returns anEnqueuedTaskPromise
Promise<EnqueuedTask>
with an extra methodwaitTask
, that first gets theEnqueuedTask
and then internally callsTaskClient.waitForTask
on it to return aPromise<Task>
, avoiding quite a bit of boilerplateConfig
:defaultWaitOptions
- used to set the default wait options forTaskClient
interval
for waiting tasks in tests, thus making tests complete often in under 2 minutesMeiliSearchTaskTimeOutError
; thrown when waiting for a task times out viawaitForTask
and its derivativesCaution
TaskClient
is no longer exported, use it throughMeilisearch
orIndex
instead, on both available astasks
propertyBatchClient
which isn't exported in the index fileBatch
class is only a type nowEnqueuedTask
class is only a type nowTask
class is only a type nowDate
before is now a stringDate
is left to the user (new Date(str)
)MeiliSearchTimeOutError
->MeiliSearchRequestTimeOutError
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!