#19444 simplify signature of FlowOps.expand
Any previous usage can be represented in this fashion while typically saving one function allocation and also saving the function literal’s syntax overhead (for the seed). Plus a new feature: the provided iterator does not have to be infinite, limiting how far expand is allowed to go.
This commit is contained in:
parent
a12451e007
commit
7463c50fc9
16 changed files with 127 additions and 151 deletions
|
|
@ -273,9 +273,7 @@ class InterpreterSpec extends AkkaSpec with GraphInterpreterSpecKit {
|
|||
lastEvents() should be(Set(Cancel))
|
||||
}
|
||||
|
||||
"implement expand" in new OneBoundedSetup[Int](Seq(Expand(
|
||||
(in: Int) ⇒ in,
|
||||
(agg: Int) ⇒ (agg, agg)))) {
|
||||
"implement expand" in new OneBoundedSetup[Int](new Expand(Iterator.continually(_: Int))) {
|
||||
|
||||
lastEvents() should be(Set(RequestOne))
|
||||
|
||||
|
|
@ -339,13 +337,9 @@ class InterpreterSpec extends AkkaSpec with GraphInterpreterSpecKit {
|
|||
|
||||
}
|
||||
|
||||
"work with expand-expand" in new OneBoundedSetup[Int](Seq(
|
||||
Expand(
|
||||
(in: Int) ⇒ in,
|
||||
(agg: Int) ⇒ (agg, agg + 1)),
|
||||
Expand(
|
||||
(in: Int) ⇒ in,
|
||||
(agg: Int) ⇒ (agg, agg + 1)))) {
|
||||
"work with expand-expand" in new OneBoundedSetup[Int](
|
||||
new Expand(Iterator.from),
|
||||
new Expand(Iterator.from)) {
|
||||
|
||||
lastEvents() should be(Set(RequestOne))
|
||||
|
||||
|
|
@ -376,14 +370,12 @@ class InterpreterSpec extends AkkaSpec with GraphInterpreterSpecKit {
|
|||
lastEvents() should be(Set(OnComplete, OnNext(12)))
|
||||
}
|
||||
|
||||
"implement conflate-expand" in new OneBoundedSetup[Int](Seq(
|
||||
"implement conflate-expand" in new OneBoundedSetup[Int](
|
||||
Conflate(
|
||||
(in: Int) ⇒ in,
|
||||
(agg: Int, x: Int) ⇒ agg + x,
|
||||
stoppingDecider),
|
||||
Expand(
|
||||
(in: Int) ⇒ in,
|
||||
(agg: Int) ⇒ (agg, agg)))) {
|
||||
stoppingDecider).toGS,
|
||||
new Expand(Iterator.continually(_: Int))) {
|
||||
|
||||
lastEvents() should be(Set(RequestOne))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue