-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add a watch method to Workflow::Runner for event driven updates #95
Conversation
b563c5c
to
1a600a6
Compare
1a600a6
to
8c06be3
Compare
31e0a78
to
53d0403
Compare
364dc19
to
8bff3b9
Compare
I'm getting distracted by Lol. Code climate is asking for you to add back |
Ahh that makes so much more sense, was wondering why we pulled that out into a separate method when it was only called in one place. |
👍 yes great idea |
cb254e9
to
2ab742c
Compare
Overall LGTM - only questions I have left are about possible JSON parsing failures as we are parsing the notices line by line. |
if timeout.to_i > 0 | ||
timeout_thread = Thread.new do | ||
sleep(timeout) | ||
watcher.finish | ||
end | ||
end |
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.
not thrilled with this.
But it is a very common pattern (i.e.: feels like go code)
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.
Yeah it is my preference for any method call that could block indefinitely to take a timeout option, otherwise this is what you have to do.
kubeclient.watch_pods(:timeout => 30.seconds)
would fix this :)
Checked commits agrare/floe@45c905b~...9369eef with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
ready = [] | ||
run_until = Time.now.utc + timeout if timeout.to_i > 0 | ||
ready = [] | ||
queue = Queue.new |
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.
Is there a concurrency concern here? i.e. should we be using something from concurrent-ruby, or is Queue thread safe enough?
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.
Is Queue
not thread-safe? We use it in ManageIQ core across threads in a few places
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.
The docs for Queue
show examples using multiple threads
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.
I can never remember hence my question - Some thing in Ruby are thread safe, others are partially and others are not. Otherwise there wouldn't be a Concurrent::Hash :(
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.
Super-high-level I'm good with this PR (have one non-blocking question above).
In the future I wonder if it makes more sense to use something like concurrent-ruby Promises or some other abstraction. I do worry that there are hidden synchronization bugs here cause threads are hard.
So one of my biggest issues with |
Add a method for getting update driven notifications about floe events
Get all updates indefinitely:
Get only create/update events for 30 seconds then break out:
TODO
Floe::Workflow.wait
to useFloe::Workflow::Runner#wait
eventsFloe::Workflow.wait