/ PLAYBOOK.scm
PLAYBOOK.scm
 1  ;; SPDX-License-Identifier: AGPL-3.0-or-later
 2  ;; SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
 3  ;; PLAYBOOK.scm — beamdeno
 4  
 5  (define-module (beamdeno playbook)
 6    #:export (workflows runbooks procedures))
 7  
 8  (define workflows
 9    '((development
10       (setup
11        (steps
12         ("Clone repository" . "git clone https://github.com/hyperpolymath/beamdeno")
13         ("Enter directory" . "cd beamdeno")
14         ("Install Erlang/OTP" . "asdf install erlang latest")
15         ("Run Deno tests" . "deno test")
16         ("Run Erlang tests" . "cd beam && rebar3 eunit")))
17       (daily
18        (steps
19         ("Pull latest" . "git pull origin main")
20         ("Run tests" . "deno test && cd beam && rebar3 eunit")
21         ("Check types" . "deno check deno/mod.ts"))))
22  
23      (release
24       (prepare
25        (steps
26         ("Update version in deno.json" . "manual")
27         ("Update version in beam/src/*.app.src" . "manual")
28         ("Update CHANGELOG.adoc" . "manual")
29         ("Run full test suite" . "deno test --coverage && cd beam && rebar3 ct")))
30       (publish
31        (steps
32         ("Create git tag" . "git tag vX.Y.Z")
33         ("Push with tags" . "git push origin main --tags")
34         ("Publish Deno package to JSR" . "deno publish")
35         ("Publish Erlang package to Hex" . "cd beam && rebar3 hex publish"))))))
36  
37  (define runbooks
38    '((incident-response
39       (connection-failure
40        (symptoms . ("Cannot connect to BEAM node" "Cookie mismatch errors"))
41        (diagnosis . ("Verify BEAM node is running" "Check cookie configuration" "Check network connectivity"))
42        (resolution . ("Restart BEAM node" "Update cookie" "Check firewall rules"))
43        (prevention . ("Health check in connection setup" "Cookie rotation procedure")))
44  
45       (etf-decode-error
46        (symptoms . ("Malformed ETF data" "Unknown term type"))
47        (diagnosis . ("Log raw binary data" "Check BEAM version compatibility"))
48        (resolution . ("Update ETF codec" "Add missing term type support"))
49        (prevention . ("Comprehensive term type tests" "Version compatibility matrix")))
50  
51       (port-crash
52        (symptoms . ("Port process died" "No response from BEAM"))
53        (diagnosis . ("Check BEAM logs" "Verify port program exists"))
54        (resolution . ("Restart port" "Fix port program crash"))
55        (prevention . ("Supervisor-based port management" "Heartbeat monitoring"))))))
56  
57  (define procedures
58    '((connecting-to-beam
59       (description . "How to establish connection to a BEAM node")
60       (steps
61        ("Start BEAM node" . "erl -sname myapp -setcookie mysecret")
62        ("Import beamdeno" . "import { BeamConnection } from 'beamdeno'")
63        ("Create connection" . "const beam = await BeamConnection.connect({ node: 'myapp@localhost', cookie: 'mysecret' })")
64        ("Call functions" . "const result = await beam.call('erlang', 'now', [])")
65        ("Close connection" . "await beam.close()")))
66  
67      (spawning-deno-from-beam
68       (description . "How to spawn and manage Deno processes from BEAM")
69       (steps
70        ("Add beamdeno to deps" . "Add to rebar.config or mix.exs")
71        ("Start Deno supervisor" . "beamdeno:start_link()")
72        ("Spawn Deno worker" . "beamdeno:spawn_worker(Script, Args)")
73        ("Send messages" . "beamdeno:send(WorkerPid, Message)")
74        ("Receive responses" . "receive {deno_response, Response} -> Response end")))
75  
76      (genserver-from-deno
77       (description . "How to call GenServer from Deno")
78       (steps
79        ("Import GenServerClient" . "import { GenServerClient } from 'beamdeno'")
80        ("Connect to server" . "const client = await GenServerClient.connect('myserver@localhost')")
81        ("Call synchronously" . "const result = await client.call({type: 'get_state'})")
82        ("Cast asynchronously" . "await client.cast({type: 'update', data: value})")
83        ("Subscribe to events" . "client.on('event', handler)")))))