Counter Campaign
This is a simple campaign that counts from a given value up to 20. It contains a single providers.stage.counter stage, which takes an input value, val, increments it by 1, and passes the updated value through the trigger for the next stage.
A conditional stage selector selects the next stage. If val is less than 20, the selector routes execution back to the same counter stage, creating a loop. Once val reaches 20, the selector chooses an empty stage instead, terminating the campaign.
Part 1: Run through the sample using maestro
NOTE: This sample assumes you’ve already installed and configured
maestro.
-
Point
maestroto the Symphony installation:maestro config use-context <context name>You can use
maestro config get-contextto check for available contexts and the current context. -
Run the counter campaign sample, which is one of the packaged samples:
maestro samples run counter-campaignYou should see outputs like:
Creating campaign counter-campaign ... done Creating campaignversion counter-campaign-v-version1 ... done Creating activation counter-activation ... done -
Check the activation status:
./maestro get activation -n counter-activation --json-path @status.stageHistory[0].outputsYou should see the activation status is 200 (OK), and the output
valis 20:STATUS VAL 200 20
Part 2: Understand the campaign
- Open
~/.symphony/campaigns/counter/campaign-version.yamlto examine the campaign definition. - The counter stage uses a
providers.stage.counterthat takes an inputvaland increment its value by 1. It then writes the value to its output, which is made avaialble tostageSelector:counter: name: "counter" provider: "providers.stage.counter" stageSelector: "${{$if($lt($output(counter,val), 20), counter, '')}}" inputs: val: "${{$trigger(val, 0)}}" - The
stageSelectorselects the next stage to be executed. In this case, it uses aifstatement in Symphony expression that checks if the stage outputvalis larger than 20. If so, it selectscounteras the next stage. Otherwise, it selects an empty stage, which causes the activation to stop. This means the counter stage will be repeatedly called untilvalreaches 20.
Part 3. Clean up
-
If you run Symphony as a process, simply shut down the process.
-
If you run Symphony on Kubernetes, delete the Symphony objects:
kubectl delete activation counter-activation kubectl delete campaignversion counter-campaign-v-version1 kubectl delete campaign counter-campaign