-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
Consider make RequestFuture more elegent? #772
Comments
> err's type is only time out error. > when err occurred Requester will know exactly what happened. > We can Define a response struct > When we use Response struct as a response value. Requester won't wait until timeOut |
> Do you mean a struct wrapper of Response and Error?Yes! But not like Option in rust. Request won't receive a wrapped Response. It should work in this way。
// request
res:= System.Root.RequestFuture(roomMgrPid, info, 1*time.Second)
// respond
resp := &Response{
Err: fooErr
RetVAlue: fooRetValue
}
context.Respond(resp)
// fooRetValue is resp.fooRetValue fooErr may be protoactor-go`s error type or resp.fooErr
fooRetValue, fooErr := res.Result() |
> Response struct isn't necessary with that case.Yes! we can use type switch to distinguish error and return value. But personally I like protoactor-go help me do this so we can. // fooRetValue is resp.fooRetValue fooErr may be protoactor-go`s error type or resp.fooErr
fooRetValue, fooErr := res.Result()
if fooErr != nil {
// Log this error
}
// do something normal |
I'm all for investigating this further. |
I also encountered this problem when I ported pubsub from csharp. Check out how I implemented a future-like structure at that time. protoactor-go/cluster/pubsub_producer.go Lines 120 to 146 in 8801eff
The logic to wait for the completion of future and determine if there are any errors is like this ⬇️ protoactor-go/cluster/pubsub_producer_test.go Lines 85 to 88 in 8801eff
May be helpful for the design of future. |
Is your feature request related to a problem? Please describe.
I`m using protoactor-go for our project.
But I found We can make RequestFuture more elegant. consider this code snippet
err`s type is only time out error. I think we have a chance to reuse it.
Describe the solution you'd like
We can Define a response struct
When we use Response struct as a response value. Requester won't wait until timeOut, and when err occurred Requester will know exactly what happened.
The text was updated successfully, but these errors were encountered: