Skip to content

Commit

Permalink
Return nil from Iteration#perform
Browse files Browse the repository at this point in the history
`perform` should be treated as `void`, with consumers not coupling to
its return value.

Explicitly returning `nil` ensures the return value does not change if
we happen to change the implementation.
  • Loading branch information
sambostock committed Aug 18, 2023
1 parent 7867dc4 commit 0395d2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/job-iteration/iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def deserialize(job_data) # @private

def perform(*params) # @private
interruptible_perform(*params)

nil
end

def retry_job(*, **)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/iteration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ def test_nested_each_iteration_instrumentation
assert_equal(expected, events)
end

def test_perform_returns_nil
# i.e. perform is "void", and nobody should depend on the return value
assert_nil(JobWithRightMethods.perform_now({}))
end

private

# Allows building job classes that read max_job_runtime during the test,
Expand Down

0 comments on commit 0395d2f

Please sign in to comment.