Last active
April 9, 2018 08:15
-
-
Save makefunstuff/2944916c88f48b212248fc8ea135ae8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def FlowExample do | |
def process(tickets_batch) do | |
customer_flow = create_customer_flow(tickets_batch) | |
messages_flow = create_messages_flow(tickets_batch) | |
Flow.bounded_join(:inner, | |
customer_flow, | |
messages_flow, | |
&(&1.number), | |
&(&1.number), | |
&TicketProcessor.update_ticket_flag/2) |> Flow.run | |
end | |
defp create_customer_flow(tickets_batch) do | |
tickets_batch | |
|> Flow.from_enumerable | |
|> Flow.partition(max_demand: 50, stages: 10) | |
|> Flow.map(&CustomerCreator.import_customer/1) | |
end | |
defp create_messages_flow(tickets_batch) do | |
tickets_batch | |
|> Flow.from_enumerable | |
|> Flow.partition(max_demand: 50, stages: 10) | |
|> Flow.map(&TicketProcessor.import_messages/1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment