-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathouroboros-loop.toml
More file actions
42 lines (37 loc) · 1.52 KB
/
Copy pathouroboros-loop.toml
File metadata and controls
42 lines (37 loc) · 1.52 KB
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
36
37
38
39
40
41
42
# Ouroboros Loop: self-seeding infinite loop
#
# Starts automatically — no manual curl needed. An exec-source seeds the
# loop, then the message circulates forever with an incrementing counter.
#
# Prerequisites:
# emergent marketplace install http-source exec-handler exec-sink
#
# Usage:
# emergent --config ./config/examples/ouroboros-loop.toml
[engine]
name = "ouroboros"
socket_path = "auto"
api_port = 0
[[sources]]
name = "webhook"
path = "~/.local/share/emergent/primitives/bin/http-source"
args = ["--port", "8088"]
publishes = ["http.request"]
[[handlers]]
name = "enrich"
path = "~/.local/share/emergent/primitives/bin/exec-handler"
args = ["-s", "http.request", "--publish-as", "loop.iteration", "--", "jq", "-c", ".body.count += 1 | .body.timestamp = now"]
subscribes = ["http.request"]
publishes = ["loop.iteration"]
[[sinks]]
name = "printer"
path = "~/.local/share/emergent/primitives/bin/exec-sink"
args = ["-s", "loop.iteration", "--", "jq", "."]
subscribes = ["loop.iteration"]
# Loopback: curls back to the webhook on each iteration AND on startup
# system.started.webhook seeds the loop, loop.iteration keeps it going
[[sinks]]
name = "loopback"
path = "~/.local/share/emergent/primitives/bin/exec-sink"
args = ["-s", "loop.iteration", "-s", "system.started.webhook", "--", "sh", "-c", "payload=$(jq -c '.body // {count:0, message:\"hello ouroboros\"}') && sleep 1 && echo \"$payload\" | curl -s -X POST -H 'Content-Type: application/json' -d @- http://localhost:8088"]
subscribes = ["loop.iteration", "system.started.webhook"]