-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
102 additions
and
56 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
TODOs: | ||
- stages_from, stage_set_ref, stage or component? need more consistency | ||
- delete Decomposer, Recomposer, and Clone. Cleanup the ip and ip_error structs | ||
- Composer memory per stream_ref | ||
- Can we split one stream into two |
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
defmodule ALF.Examples.ComposerWithStreamsTest do | ||
use ExUnit.Case, async: true | ||
|
||
defmodule Pipeline do | ||
use ALF.DSL | ||
|
||
@components [ | ||
composer(:sum_and_emit, memo: 0) | ||
] | ||
|
||
def sum_and_emit(event, memo, _) do | ||
sum = event + memo | ||
|
||
if sum > 5 do | ||
{[sum], 0} | ||
else | ||
{[], event + memo} | ||
end | ||
end | ||
end | ||
|
||
setup do | ||
Pipeline.start(sync: true) | ||
on_exit(&Pipeline.stop/0) | ||
end | ||
|
||
test "one stream" do | ||
results = | ||
[1, 2, 3, 4, 5] | ||
|> Pipeline.stream() | ||
|> Enum.to_list() | ||
|
||
assert results == [6, 9] | ||
end | ||
|
||
test "several streams" do | ||
stream1 = Pipeline.stream(1..5) | ||
stream2 = Pipeline.stream(1..5) | ||
stream3 = Pipeline.stream(1..5) | ||
|
||
[result1, result2, result3] = | ||
[stream1, stream2, stream3] | ||
|> Enum.map(&Task.async(fn -> Enum.to_list(&1) end)) | ||
|> Task.await_many() | ||
|
||
assert [result1, result2, result3] == [[6, 9], [6, 9], [6, 9]] | ||
end | ||
end |
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