Description
Some actions in MeiliSearch are asynchronous (documents manipulation, settings...). The associated methods in the SDKs return information about the update
with an enqueued
status and we don't know when the action is processed.
We already provide, for most of the SDKs, the waitForPendingUpdate
method (related #1). But it means this kind of usage (in ruby):
update = index.add_documents(...)
index.wait_for_pending_update(update['updateId'])
Suggestion 1
We could provide a "wait" version of each method for better user experience, for example:
index.add_documents_wait(...)
Naming
First of all, how can we name these methods?
A simple way would be to add a suffix to each method. I suggested wait
without thinking about it a lot. So, I would like to read your ideas 🙂
Coding
Instead of re-coding all the methods, we could find a way to generate the version of each concerned method, because there are just the same but with a wait_for_pending_update
method.
The goal is to avoid code duplication.
I haven't investigated this part yet.
Suggestion 2
index.add_documents(...).wait_for_pending_update()
Not sure if this solution is more user friendly than the other one. Investigation needed 😁
Coding
This solution would imply changing the return of all the current methods (big breaking). They should return an Update
object instead of a JSON object containing information about the update. This Update
object should contain the wait_for_pending_update
method.
Suggestion 3
def add_documents(documents, primary_key = nil, wait_for_update = false)
This solution might be the easiest one to code, but problem with the Go!
A solution could be not to provide these methods for the Go language and wait for the demand/help of the community. Do not forget the WaitForPendingUpdate
method is already available in the SDK Go.
Conclusion
Even if you would rather have other suggestions than suggestion 1, I really like having your suggestions of naming for the suggestion 1, so that we can really compare them in term of user experience.
Suggestion 1 doesn't imply any breaking but we have to find a way to generate the code in every language. And a lot of tests would be added, at least one for each new method.
Suggestion 2 involves big breaking but seems easy to code: just an Update
object to add.
Suggestion 3 is the easiest one to code, and does not imply any breaking, but problem with the Go language! A lot of tests would be needed too.
=> The goal is to find what is the more user-friendly for our users, not only what we would like to code because it's easier 😇