-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
492: feat!: enhanced enumeration for task types & statuses r=curquiza a=42atomys ## Related issue Fixes #491 ## What does this PR do? This PR addresses the lack of clear definitions for `TaskType` in our asynchronous task definition. While `TaskStatus` is well-defined, `TaskType` currently uses generic strings which could lead to confusion and maintenance challenges. By providing a definitive list of types, we enhance clarity, improve code readability, and set the groundwork for easier maintenance in future SDK versions. ##⚠️ Breaking Change: Enhanced Enumeration for Task Types & Statuses The Meilisearch Go client has undergone a significant enhancement in how it handles task types and statuses. In prior versions, developers interfaced with tasks using generic strings. This methodology, while functional, lacked clarity and posed maintenance challenges. `TaskType` and `TaskStatus` have transitioned from generic strings to definitive constants. This change augments code clarity, minimizes potential errors, and paves the way for smoother future updates. **Quick Exemple** ```go // Before: taskType := "documentDeletion" ... // After: taskType := meilisearch.TaskTypeDocumentDeletion ``` **Real world example** ```go // Before: func Before() { resp, _ := meilisearchClient.GetTasks(&meilisearch.TasksQuery{ Statuses: []string("enqueued", "processing"), Types: []string("documentDeletion", "documentAdditionOrUpdate"), }) for _, task := range resp.Results { if task.Status == "processing" { // ... } if task.Type == "documentDeletion" { // ... } } } // After: func After() { resp, _ := meilisearchClient.GetTasks(&meilisearch.TasksQuery{ Statuses: []meilisearch.TaskStatus{ meilisearch.TaskStatusEnqueued, meilisearch.TaskStatusProcessing, }, Types: []meilisearch.TaskType{ meilisearch.TaskTypeDocumentDeletion, meilisearch.TaskTypeDocumentAdditionOrUpdate, }, }) for _, task := range resp.Results { if task.Status == meilisearch.TaskStatusProcessing { // ... } if task.Type == meilisearch.TaskTypeDocumentDeletion { // ... } } } ``` ## 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: Atomys <[email protected]> Co-authored-by: 42Atomys <[email protected]>
- Loading branch information
Showing
9 changed files
with
177 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.