Skip to content

Instantly share code, notes, and snippets.

@makefunstuff
Created April 9, 2018 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makefunstuff/91f1a88a9eaed2409e8dc800c12c7d30 to your computer and use it in GitHub Desktop.
Save makefunstuff/91f1a88a9eaed2409e8dc800c12c7d30 to your computer and use it in GitHub Desktop.
defmodule NaiveSolution do
def process(tickets_batch) do
tickets
|> Enum.map(&async_process/1)
|> Enum.map(&Task.await/1)
end
def async_process(ticket) do
Task.async fn() ->
ticket
# fetching messages for ticket from 3rd party api
|> fetch_messages
# fetching customer data from 3rd party api
|> fetch_customer
# insert fetched data
|> update
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment