forked from Comcast/plax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic-pub.yaml
35 lines (35 loc) · 1.07 KB
/
dynamic-pub.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
doc: |
A bindings example that generates a message based on runtime input.
labels:
- selftest
spec:
phases:
phase1:
steps:
- '$include<include/mock.yaml>'
- pub:
doc: |
Publish a message to ourself to simulate an incoming message.
payload: '{"want":"tacos","n":3}'
- recv:
doc: |
Receive what we just published. Bind a pattern variable.
pattern: '{"want":"?wanted","n":"?n"}'
- run: |
// Make a new binding based on what we just heard.
test.Bindings["?m"] = test.Bindings["?n"] * 10;
test.Bindings["?rnd"] = Math.random();
- pub:
doc: |
Publish a message that includes variables with values we
provided or got during pattern matching.
payload:
deliver: "?wanted"
n: "?n"
m: "?m"
r: "?rnd"
- recv:
doc: Check part of that message.
pattern:
deliver: tacos
m: 30