-
Notifications
You must be signed in to change notification settings - Fork 52
Support nested iteration #310
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
Conversation
dc4d1b6
to
40ed3ef
Compare
Thanks for working on this! I tested locally all the edge cases, seems like it is working correctly 👍. I haven't grasped your suggestion initially, because with these changes current cursor |
@Mangara anything I can do to help get this over the finish line? |
494231f
to
fea96ac
Compare
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 code LGTM. Just one question and a test failure.
Thank you @fatkodima for starting this, and @bdewater for finishing it ❤️
lib/job-iteration/iteration.rb
Outdated
@@ -189,7 +189,7 @@ def iterate_with_enumerator(enumerator, arguments) | |||
# Deferred until 2.0.0 | |||
# assert_valid_cursor!(cursor_from_enumerator) | |||
|
|||
tags = instrumentation_tags.merge(cursor_position: cursor_from_enumerator) | |||
tags = instrumentation_tags.merge(cursor_position: cursor_from_enumerator).deep_dup |
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.
Why is this necessary?
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.
To be honest I'm not entirely sure why this is happening, but the added test in test/unit/iteration_test.rb
fails otherwise: the notification payload is 12 times {:job_class=>"JobIterationTest::JobWithNestedEnumerator", :cursor_position=>[2, nil]}
instead of the expected increasing nested cursor 🤔
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 seems to hang on to @cursors
yielded from the nested enumerator.
irb(#<JobIterationTest:0x00000001066631c0>):003:0> events.map { |e| e[:cursor_position].object_id }
=> [243980, 243980, 243980, 243980, 243980, 243980, 243980, 243980, 243980, 243980, 243980, 243980]
cursor_from_enumerator.dup
instead of the tags object works too, I'll push that up in a sec.
fea96ac
to
baf2cf0
Compare
Co-authored-by: Bart de Water <[email protected]>
baf2cf0
to
d6ba2c9
Compare
Alternate take on #295 - unlike the suggested fix in that PR, we retain the existing "start after" cursor logic this gem uses (see eg array and CSVEnumerator):
cursor: nil
yields the first itemcursor: 0
yields the second itemcursor: 1
yields the third itemThe main difference in code:
cc @fatkodima
closes #295