Skip to content

Instantly share code, notes, and snippets.

@marionzualo
Last active December 14, 2016 07:34
Show Gist options
  • Save marionzualo/ed48b6f3e4bb472eec43bff0d55e129a to your computer and use it in GitHub Desktop.
Save marionzualo/ed48b6f3e4bb472eec43bff0d55e129a to your computer and use it in GitHub Desktop.
Fibers third example
def complex_operation_in_background_with_recursion(batch_index = 0)
chunk_size = 2
batch = query_batch(batch_index, chunk_size)
return if batch.length == 0
process_batch(batch)
complex_operation_in_background_with_recursion(batch_index + 1)
end
# Execution in the terminal
# >> complex_operation_in_background_with_recursion
# ["Vhils", "AKACORLEONE"]
# ["Pixel Pancho", "+-"]
# ["Kruella D'Enfer", "Tamara Alves"]
# ["Add Fuel", "MAR"]
# ["Eime", "Bordalo II"]
# ["Felipe Pantone", "Ernest Zacharevic"]
# ["Wasted Rita", "Sainer"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment