-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track batch execution via inspector.
- Loading branch information
Showing
6 changed files
with
102 additions
and
18 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
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
27 changes: 9 additions & 18 deletions
27
formula/src/test/java/com/instacart/formula/types/IncrementActionFormula.kt
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,36 +1,27 @@ | ||
package com.instacart.formula.types | ||
|
||
import com.instacart.formula.Evaluation | ||
import com.instacart.formula.Formula | ||
import com.instacart.formula.Snapshot | ||
import com.instacart.formula.StatelessFormula | ||
import com.instacart.formula.Transition | ||
import com.instacart.formula.test.Relay | ||
|
||
class IncrementActionFormula( | ||
private val incrementRelay: Relay, | ||
private val executionType: Transition.ExecutionType? = null, | ||
) : StatelessFormula<Unit, Int>() { | ||
) : Formula<Unit, Int, Int>() { | ||
override fun initialState(input: Unit): Int { | ||
return 0 | ||
} | ||
|
||
private val actionInput = ActionDelegateFormula.Input( | ||
delegateAction = { | ||
if (executionType == null) { | ||
incrementRelay.action().onEvent { | ||
transition(state + 1) | ||
} | ||
} else { | ||
override fun Snapshot<Unit, Int>.evaluate(): Evaluation<Int> { | ||
return Evaluation( | ||
output = state, | ||
actions = context.actions { | ||
incrementRelay.action().onEventWithExecutionType(executionType) { | ||
transition(state + 1) | ||
} | ||
} | ||
}, | ||
onAction = {} | ||
) | ||
|
||
private val actionFormula = ActionDelegateFormula() | ||
|
||
override fun Snapshot<Unit, Unit>.evaluate(): Evaluation<Int> { | ||
return Evaluation( | ||
output = context.child(actionFormula, actionInput) | ||
) | ||
} | ||
} |