-
Notifications
You must be signed in to change notification settings - Fork 87
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
Redesign update API to task API #262
Conversation
fcdcc9b
to
7f764bf
Compare
7f764bf
to
39f033c
Compare
client.go
Outdated
GetTask(taskID int64) (resp *Task, err error) | ||
GetTasks() (resp *ResultTask, err error) | ||
WaitForTask(ctx context.Context, interval time.Duration, taskID *Task) (*Task, error) | ||
DefaultWaitForTask(taskID *Task) (*Task, error) |
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.
What is defaultWaitForTask
?
I see that it is when you provide the default values. Is this the naming convention in GO ?
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.
It is the WaitForTask
with default values. I don't think this naming is a specific convention in go. I can rename it if you have a better naming 🤩
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.
in waitForTask
you can add a structure the following way
type waitParams struct{
interval: int,
taskId: int
}
provide this as a parameter and in case of null use the default value?
function waitForTask(taskId: int, params WaitParams) {
var interval = 500 // default value
if (params.interval != 0) {
interval = params.interval
}
// etc ...
}
would something like that be possible?
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.
Yes, but you had to specify the last param at nil
like:
client. waitForTask(0, nil)
There is no optional parameters in golang
but I can use variadic args and do something like:
func (c *Client) WaitForTask(task *Task, options ...waitParams) (*Task, error) {
if (options == nil) {
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*5)
defer cancelFunc()
options[0].Context = ctx
options[0].Interval = time.Millisecond*50
}
... do waitForTask ...
}
And I can use it like:
client. waitForTask(0)
// OR
client. waitForTask(0, &waitParams{ctx, time.Millisecond*10})
I'm not sure which one is the most elegant because in the second option I get the waitParams
as an array.
What do you think?
Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>
1f93476
to
1e5c2ff
Compare
1e5c2ff
to
870833a
Compare
I like the variadic args! I'm not so used to goland so I hope it is something that is not choking to the user |
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 🔥
Me too! |
bors merge |
247: Changes related to the next MeiliSearch release (v0.25.0) r=alallema a=meili-bot Related to this issue: meilisearch/integration-guides#157 This PR: - gathers the changes related to the next MeiliSearch release (v0.25.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases). - might eventually contain test failures until the MeiliSearch v0.25.0 is out.⚠️ This PR should NOT be merged until the next release of MeiliSearch (v0.25.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._ Done: - #254 - #255 - #256 - #257 - #262 - #264 - #265 - #266 Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com> Co-authored-by: Amélie <alallema@users.noreply.github.com> Co-authored-by: alallema <amelie@meilisearch.com> Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Breaking Changes
All the actions on indexes are now asynchronous:
CreateIndex()
,UpdateIndex()
,DeleteIndex()
return aTask
response instead of anIndex
.index.Create
andindex.Delete
from index return atask
.WaitForPendingUpdate()
WaitForTask
index.WaitForTask()
method call/tasks/:uid
index.GetUpdateStatus
is renamedindex.GetTask
index.GetAllUpdateStatus
is renamedindex.GetTasks
Notes: The only two methods that now return an
Index
areclient.Index()
andclient.GetIndex()
Enhancements
client.WaitForTask()
call/tasks/:uid
client.WaitForTask()
client.GetTasks
that calls/tasks
client.GetTask
that calls/tasks/:uid