v0.26.0 🐹
meili-bot
released this
02 Nov 16:29
·
195 commits
to refs/heads/main
since this release
⚠️ Breaking changes: 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
// Before:
taskType := "documentDeletion"
...
// After:
taskType := meilisearch.TaskTypeDocumentDeletion
Real world example
// 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 {
// ...
}
}
}
🚀 Enhancements
Thanks again to @42atomys, @curquiza, @datbeohbbh, and @tadejsv! 🎉