-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
The following code with custom label generates incorrect graph visualization:
import ru.fix.completable.reactor.graph.kotlin.Graph
import kotlin.random.Random
class ExampleGraph : Graph<ExamplePayload>() {
private val generate = suspendHandler {
Random.nextInt(-10, 10)
}.withRoutingMerger router@{
if (it == 0) {
return@router Flow.ZERO
}
if (it < 0) {
Flow.NEGATIVE
} else {
Flow.POSITIVE
}
}
private val positive = suspendHandler { }.withoutMerger()
private val negative = suspendHandler { }.withoutMerger()
private val zero = suspendHandler { }.withoutMerger()
private enum class Flow {
POSITIVE,
NEGATIVE,
ZERO
}
init {
payload().handleBy(generate)
generate
.on(Flow.POSITIVE).handleBy(positive)
.on(Flow.NEGATIVE).handleBy(negative)
.on(Flow.ZERO).handleBy(zero)
positive.onAny().complete()
negative.onAny().complete()
zero.onAny().complete()
coordinates()
.pd(3, -126)
.vx(negative, 33, 148)
.vx(positive, -155, 143)
.vx(zero, 261, 118)
.vx(generate, 32, -50, 56, 31);
}
}Here is visualization:
But if we will change generate vertex code to the following:
private val generate = suspendHandler {
Random.nextInt(-10, 10)
}.withRoutingMerger {
if (it == 0) {
return@withRoutingMerger Flow.ZERO
}
if (it < 0) {
Flow.NEGATIVE
} else {
Flow.POSITIVE
}
}iilnar
Metadata
Metadata
Assignees
Labels
No labels

