-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Part #1 of synchronous requests: Add channels and a mechanism for waiting #166
Conversation
select { | ||
case obj = <-out: | ||
return obj, nil | ||
case <-tick: |
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.
you could directly do: case <- time.After(timeout)
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.
+1
I had some other ideas on how to do this... let's chat tomorrow, maybe what I'm thinking won't work. |
Something you can consider is keeping the synchronous operation and just wrapping the call in a goroutine.
|
Ok, I discussed this offline w/ @lavalamp and we came up with the following approach, I added a MakeAsync method that is used by the registries now, this means that individual storage's don't need deal in containers. Take another look and let me know what you think. |
I would have thought the MakeAsync logic would be around the |
|
||
func MakeAsync(fn func() interface{}) <-chan interface{} { | ||
channel := make(chan interface{}, 1) | ||
go func() { channel <- fn() }() |
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.
inside this goroutine: defer util.HandleCrash()
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.
Done.
The problem with the go routine wrapping the whole thing is that you don't get immediate feedback for validation errors. In this approach, you get an immediate error if the request isn't accepted, and then you get a channel that you can optionally wait on for the result. |
func MakeAsync(fn func() interface{}) <-chan interface{} { | ||
channel := make(chan interface{}, 1) | ||
go func() { | ||
util.HandleCrash() |
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.
Has to be deferred, or it won't work. :)
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.
Done (oops!)
Comments addressed, ptal. Thanks |
Part #1 of synchronous requests: Add channels and a mechanism for waiting
btw, @brendandburns @brendanburns-- I'm working on some changes to cloudcfg, so you don't need to update that. |
enable storage cache for influxdb
Fix typos in init container design.
V1.7.7 patchset
…-default Add a sane default constructor for the Etcd and EtcdConfig structs
Rebase 1.19.0-rc.2
This reverts commit 278ece378a5054f16a07622b51ddaf82b328d6e6, reversing changes made to 2df71ebbae66f39338aed4cd0bb82d2212ee33cc.
* field capture * update deployment specs to 1.1.4 for whereami * fixed emoji bug * updated readme example for path suffix * make_response in app.py not needed * json module in app.py not needed either * missing paren in readme to address issue kubernetes#166
Respective registries don't actually implement the channel behavior yet.