meilisearch / meilisearch-dart

The Meilisearch API client written for Dart

Home Page:https://meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose functions to wait for tasks

ahmednfwela opened this issue · comments

The functions defined in
https://github.com/meilisearch/meilisearch-dart/blob/main/test/utils/wait_for.dart

should be exposed in the main library, in addition to waitForTasks

Hi @ahmednfwela, there has been a long long long discussion about this subject, and I don't want to move this function to the public yet.
But, tell me, what is your use case to need those functions?

Well the main problem is that the server completes the request instantly instead of the expected behavior of waiting until completion.
So imagine a user deleting an Item from a table then doing a refresh, since the request would complete instantly, the refresh will happen and the user will still see the deleted item in the search request since it didn't get deleted yet.

This can be solved by using waitFor polling mechanism, or websockets to inform the client of task completions.

Indeed that's the current behavior, and the problem is the user can be locked until Meilisearch finally processes the task. This is my main concern with the whole waitForTask thing.
If the current instance is processing a lot of tasks, in the end, the user will have to wait for all the tasks in the queue to be finished to process their task finally.
The queue is shared between every index, and a dump task is prioritized.

In any case, all the other SDKs have this method publically, so I'm open to publicizing these methods for the Dart SDK if more users explicitly let us know their needs (a 👍 in the issue can work).

I'll close this issue since this subject could be discussed more broadly in the integration-guides here meilisearch/integration-guides#243