-
Notifications
You must be signed in to change notification settings - Fork 0
/
distributed-gleam.html
617 lines (535 loc) · 48.3 KB
/
distributed-gleam.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2023-04-13 Thu 01:33 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Gleam OTP Design Principles User's Guide</title>
<meta name="generator" content="Org Mode" />
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
<link rel="stylesheet" href="tufte.css" type="text/css" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">
</head>
<body>
<div id="content" class="content">
<h1 class="title">Gleam OTP Design Principles User's Guide</h1>
<p>
This document is a work in progress and will be updated as time permits.
</p>
<div id="outline-container-org447fe26" class="outline-2">
<h2 id="org447fe26">Overview</h2>
<div class="outline-text-2" id="text-org447fe26">
<p>
The OTP design principles define how to structure Gleam code in terms of processes and modules.
</p>
</div>
<div id="outline-container-org5faf350" class="outline-3">
<h3 id="org5faf350">Supervisor Tree</h3>
<div class="outline-text-3" id="text-org5faf350">
<p>
A fundamental idea of most BEAM based language is the ability to supervise a process, and be notified of its failure.
This supervisory idea has roots in the erlang history and has become a well accepted method to deal with process failure.
</p>
<p>
There can be a heirachy of workers and supervisors, otherwise known as "the supervision tree".
</p>
<p>
Workers are processes that perform computations, that is they have work to do.
</p>
<ul class="org-ul">
<li>A supervisor can monitor the behaviour of workers.</li>
<li>A supervisor can restart aworker if something goes wrong.</li>
<li>A worker can notify a superivsor if something goes wrong.</li>
<li>A supervisor has different modes of dealing with worker failure.</li>
</ul>
<p>
Designing software that uses the supervision tree pattern can allow a developer to create highly resiliant software.
</p>
<p>
In the following figure, square boxes represents supervisors and circles represent workers:
</p>
<div id="org20d7157" class="figure">
<p><img src="supervisors_and_processes.png" alt="supervisors_and_processes.png" />
</p>
</div>
<p>
Supervisors can supervise workers, and supervisors can supervise supervisors.
</p>
</div>
</div>
<div id="outline-container-orgdca9a75" class="outline-3">
<h3 id="orgdca9a75">Simple Processes example.</h3>
<div class="outline-text-3" id="text-orgdca9a75">
<p>
Before understanding the worker/supervisor implementation, We should create a basic example
of starting a 'process' and sending messages to it.
</p>
<p>
A process is not a OS level process, it is a 'thread' running within the single <a href="https://www.erlang.org/blog/a-brief-beam-primer/">BEAM</a>
virtual machine process. It doesn't come with the memory use and synchronization requirements that
traditional operating sytem thread or processes require.
</p>
</div>
</div>
<div id="outline-container-orgd4afefb" class="outline-3">
<h3 id="orgd4afefb">Starting a process.</h3>
<div class="outline-text-3" id="text-orgd4afefb">
<p>
A process can be started with "process.start", see the following:
</p>
<pre class="example">
import gleam/erlang/process
...
let assert pid = process.start(running: start_process, linked: False)
</pre>
<p>
The first parameter is the function to run within the newly spawned process. This function has
no arguements and returns no finished value, I like to use start_process to set the initial
state, then enter the main loop which will continue to deal with messages sent to this process.
</p>
<p>
The second parameter "linked: true", creates a "link" between two processes.
If either of the proccesses participating ink a link terminates, it will send an exit message to
the other participant. The exit message will contain the reason of the terminated participant.
</p>
<p>
In this simple example, there is no need to know if a process has terminated as no action will be taken. This
is not a supervisor.
</p>
</div>
</div>
<div id="outline-container-org192af43" class="outline-3">
<h3 id="org192af43">Sending messages</h3>
<div class="outline-text-3" id="text-org192af43">
<p>
Gleam’s process requires type safety for both processes and messages. When sending messages between
processes, the first step is to have a 'subject' which references the spawned process.
</p>
<p>
You can do this with process.new_subject, that makes a subject based in the current process context.
</p>
<p>
Subject is an opaque type. An opaque type is a type where the constructors of that type arent
exposed to other modules that import the type. You must use the "new_subject" call to create a new subject.
</p>
<p>
If the "new_subject" call is made in a different process, it would have different contents.
</p>
<div class="org-src-container">
<pre class="src src-gleam"><span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">my_subject</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">new_subject</span><span style="color: #eaeaea; background-color: #000000;">()</span>
</pre>
</div>
<p>
This reference is used to message the process that created the subject. When a new process
is started, unless a subject is created in this new process context and the subject messaged
back to the parent process, the parent process will be unable to message the child.
</p>
<p>
As messages are strictly typed, you must create a Type that can encapsulate the needs of the
data being sent to the process, including subject data being sent between them.
</p>
<p>
The example below shows a types used in both Sending and Receiving from this newly spawned process.
</p>
<p>
ChannelResponse type (from the new process)
</p>
<div class="org-src-container">
<pre class="src src-gleam"><span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">type</span> <span style="color: #7aa6da;">ChannelResponse</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #7aa6da;">ChildSubject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">Subject</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelRequest</span><span style="color: #e7c547; background-color: #000000;">)</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #7aa6da;">Allocated</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da; font-style: italic;">id</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">Int</span><span style="color: #70c0b1; background-color: #000000;">)</span> <span style="color: #969896; font-style: italic;">// additional message that the process can respond with.</span>
<span style="color: #7aa6da;">None</span> <span style="color: #969896; font-style: italic;">// additional message that the process can respond with.</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
</pre>
</div>
<p>
and the ChannelRequest type (to the new process)
</p>
<div class="org-src-container">
<pre class="src src-gleam"><span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">type</span> <span style="color: #7aa6da;">ChannelRequest</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #7aa6da;">Allocate</span>
<span style="color: #7aa6da;">Show</span>
<span style="color: #7aa6da;">Free</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelResponse</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
</pre>
</div>
<p>
As stated earlier, to be able to send to the process, a subject in the new process context will need to be sent
to the parent process.
</p>
<p>
This message will need to be captured and used when making the request. Below is a sequence diagram showing the basics of
starting processes.
</p>
<div id="orgef6f483" class="figure">
<p><img src="hello-uml.png" alt="hello-uml.png" />
</p>
</div>
<p>
After the "Child subject" has been received by the parent process, it can be used by the parent process
or passed to another, However the typed messages to the Child must remain consistent. The "Send" channel
remains the same as long as the Child Process lives.
</p>
<p>
Messages can be set to a target subject with the 'process.send'. The example allocate below is a simple
message of type "ChannelRequest" with no parameters. More complex data can be passed with more complex Types
if required.
</p>
<div class="org-src-container">
<pre class="src src-gleam"><span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">Allocate</span><span style="color: #eaeaea; background-color: #000000;">)</span>
</pre>
</div>
<p>
Listed below is a module (derived from its filename called "aserver" It is an example of a process sending a
message to another process using the method described above.
</p>
<p>
It contains some more advanced functionality that we will touch on later.
</p>
<div class="org-src-container">
<pre class="src src-gleam">
<span style="color: #b9ca4a;">import</span> gleam/io
<span style="color: #b9ca4a;">import</span> gleam/int
<span style="color: #b9ca4a;">import</span> gleam/list
<span style="color: #b9ca4a;">import</span> gleam/erlang/process<span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #eaeaea; background-color: #000000;">{</span><span style="color: #7aa6da;">Subject</span><span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">import</span> gleam/result
<span style="color: #b9ca4a;">import</span> gleam/function
<span style="color: #b9ca4a;">import</span> gleam/iterator<span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #eaeaea; background-color: #000000;">{</span><span style="color: #e78c45;">iterate</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e78c45;">take</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e78c45;">to_list</span><span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">type</span> <span style="color: #7aa6da;">ChannelResponse</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #7aa6da;">Allocated</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da; font-style: italic;">id</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">Int</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #7aa6da;">None</span>
<span style="color: #7aa6da;">ChildSubject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">Subject</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelRequest</span><span style="color: #e7c547; background-color: #000000;">)</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">type</span> <span style="color: #7aa6da;">ChannelRequest</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #7aa6da;">Allocate</span>
<span style="color: #7aa6da;">Show</span>
<span style="color: #7aa6da;">Free</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelResponse</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">alloc</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">mine</span> <span style="color: #eaeaea; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">Allocate</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #b9ca4a;">assert</span> <span style="color: #7aa6da;">Ok</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">allocation</span><span style="color: #70c0b1; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">receive</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">mine</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da; font-style: italic;">within</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">1000</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #e7c547;">allocation</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">free</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">mine</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channel</span><span style="color: #eaeaea; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">Free</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #e7c547;">channel</span><span style="color: #e7c547; background-color: #000000;">)</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">show</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">mine</span><span style="color: #eaeaea; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">target</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">Show</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #969896; font-style: italic;">// generate a list of 100 channels for init.</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">generate_channel_list</span><span style="color: #eaeaea; background-color: #000000;">()</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #e78c45;">iterate</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">1</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #b9ca4a;">fn</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #e7c547;">n</span><span style="color: #e7c547; background-color: #000000;">)</span> <span style="color: #e7c547; background-color: #000000;">{</span> <span style="color: #7aa6da;">1</span><span style="color: #b9ca4a;">+</span><span style="color: #e7c547;">n</span> <span style="color: #e7c547; background-color: #000000;">}</span><span style="color: #70c0b1; background-color: #000000;">)</span> <span style="color: #b9ca4a;">|></span> <span style="color: #e78c45;">take</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">100</span><span style="color: #70c0b1; background-color: #000000;">)</span> <span style="color: #b9ca4a;">|></span> <span style="color: #e78c45;">to_list</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">main</span><span style="color: #eaeaea; background-color: #000000;">()</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #e7c547;">io</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">println</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #70c0b1;">"Hello from non_gen_server!"</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// similar to a channel between the process to start</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">my_subject</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">new_subject</span><span style="color: #70c0b1; background-color: #000000;">()</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">thing</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #b9ca4a;">fn</span><span style="color: #70c0b1; background-color: #000000;">()</span> <span style="color: #70c0b1; background-color: #000000;">{</span> <span style="color: #e78c45;">init</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #e7c547; background-color: #000000;">)</span><span style="color: #70c0b1; background-color: #000000;">}</span>
<span style="color: #969896; font-style: italic;">// why do i block here ?</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #b9ca4a;">assert</span> <span style="color: #e7c547;">pid</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">start</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da; font-style: italic;">running</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #e7c547;">thing</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da; font-style: italic;">linked</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">True</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// the channel from the child</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #b9ca4a;">assert</span> <span style="color: #7aa6da;">ChildSubject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span><span style="color: #eaeaea; background-color: #000000;">=</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">receive</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da; font-style: italic;">within</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">100_000_000</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #b9ca4a;">|></span> <span style="color: #e7c547;">result</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">unwrap</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">None</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// show the default channels.</span>
<span style="color: #e78c45;">show</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// get three channels.</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">channel1</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e78c45;">alloc</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">channel2</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e78c45;">alloc</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">channel3</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e78c45;">alloc</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// use the channels here.</span>
<span style="color: #969896; font-style: italic;">// use_channels</span><span style="color: #70c0b1; font-style: italic;">(</span><span style="color: #969896; font-style: italic;">channel1, channel2, channel3</span><span style="color: #70c0b1; font-style: italic;">)</span>
<span style="color: #969896; font-style: italic;">// show the free channel list:</span>
<span style="color: #e78c45;">show</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// return the channels, as we're done with them.</span>
<span style="color: #e78c45;">free</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channel1</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #e78c45;">free</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channel2</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #e78c45;">free</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channel3</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// show the newly used list, they will be out of order.</span>
<span style="color: #e78c45;">show</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">child_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">my_subject</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #7aa6da;">Ok</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">sleep_forever</span><span style="color: #e7c547; background-color: #000000;">()</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">init</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">Subject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelResponse</span><span style="color: #70c0b1; background-color: #000000;">)</span><span style="color: #eaeaea; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #969896; font-style: italic;">// create another subject, that other processes can use</span>
<span style="color: #969896; font-style: italic;">// to address this new process.</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">my_subject</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">new_subject</span><span style="color: #70c0b1; background-color: #000000;">()</span>
<span style="color: #969896; font-style: italic;">// send the new subject back to the parent, using its subject.</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">ChildSubject</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #e7c547; background-color: #000000;">)</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// start the main process loop</span>
<span style="color: #e78c45;">loop</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e78c45;">generate_channel_list</span><span style="color: #e7c547; background-color: #000000;">()</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
<span style="color: #b9ca4a;">pub</span> <span style="color: #b9ca4a;">fn</span> <span style="color: #e78c45;">loop</span><span style="color: #eaeaea; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">Subject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelRequest</span><span style="color: #70c0b1; background-color: #000000;">)</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">Subject</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">ChannelResponse</span><span style="color: #70c0b1; background-color: #000000;">)</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channels</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #7aa6da;">List</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da;">Int</span><span style="color: #70c0b1; background-color: #000000;">)</span><span style="color: #eaeaea; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">{</span>
<span style="color: #969896; font-style: italic;">// add a selector to listen from parent process.</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">sel</span> <span style="color: #eaeaea; background-color: #000000;">=</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">new_selector</span><span style="color: #70c0b1; background-color: #000000;">()</span>
<span style="color: #b9ca4a;">|></span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">selecting</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #7aa6da; font-style: italic;">for</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da; font-style: italic;">mapping</span><span style="color: #eaeaea; background-color: #000000;">:</span> <span style="color: #e7c547;">function</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">identity</span> <span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #969896; font-style: italic;">// block forever on waiting for a message.</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">msg</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">select_forever</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">sel</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #e7c547;">new_channels</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #b9ca4a;">case</span> <span style="color: #e7c547;">msg</span> <span style="color: #70c0b1; background-color: #000000;">{</span>
<span style="color: #7aa6da;">Allocate</span><span style="color: #e7c547; background-color: #000000;">()</span> <span style="color: #eaeaea; background-color: #000000;">-></span> <span style="color: #e7c547; background-color: #000000;">{</span>
<span style="color: #969896; font-style: italic;">// choose the first value, return rest for new state</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #b9ca4a; background-color: #000000;">[</span><span style="color: #e7c547;">next_available</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #eaeaea; background-color: #000000;">..</span> <span style="color: #e7c547;">rest</span> <span style="color: #b9ca4a; background-color: #000000;">]</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">channels</span>
<span style="color: #e7c547;">process</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">send</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #7aa6da;">Allocated</span><span style="color: #7aa6da; background-color: #000000;">(</span><span style="color: #e7c547;">next_available</span><span style="color: #7aa6da; background-color: #000000;">)</span><span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547;">io</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">debug</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #70c0b1;">"allocating channel "</span> <span style="color: #b9ca4a;"><></span> <span style="color: #e7c547;">int</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">to_string</span><span style="color: #7aa6da; background-color: #000000;">(</span><span style="color: #e7c547;">next_available</span><span style="color: #7aa6da; background-color: #000000;">)</span> <span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547;">rest</span>
<span style="color: #e7c547; background-color: #000000;">}</span>
<span style="color: #7aa6da;">Free</span><span style="color: #e7c547; background-color: #000000;">(</span><span style="color: #e7c547;">id</span><span style="color: #e7c547; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">-></span> <span style="color: #e7c547; background-color: #000000;">{</span>
<span style="color: #b9ca4a;">let</span> <span style="color: #b9ca4a;">assert</span> <span style="color: #7aa6da;">Allocated</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #e7c547;">channel</span><span style="color: #b9ca4a; background-color: #000000;">)</span> <span style="color: #eaeaea; background-color: #000000;">=</span> <span style="color: #e7c547;">id</span>
<span style="color: #e7c547;">io</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">debug</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #70c0b1;">"Freeing channel: "</span> <span style="color: #b9ca4a;"><></span> <span style="color: #e7c547;">int</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">to_string</span><span style="color: #7aa6da; background-color: #000000;">(</span><span style="color: #e7c547;">channel</span><span style="color: #7aa6da; background-color: #000000;">)</span><span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547;">list</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">append</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #7aa6da; background-color: #000000;">[</span><span style="color: #e7c547;">channel</span><span style="color: #7aa6da; background-color: #000000;">]</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">channels</span><span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547; background-color: #000000;">}</span>
<span style="color: #7aa6da;">Show</span> <span style="color: #eaeaea; background-color: #000000;">-></span> <span style="color: #e7c547; background-color: #000000;">{</span>
<span style="color: #e7c547;">io</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">debug</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #70c0b1;">"Available channels: !"</span><span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547;">io</span><span style="color: #eaeaea; background-color: #000000;">.</span><span style="color: #e78c45; font-style: italic;">debug</span><span style="color: #b9ca4a; background-color: #000000;">(</span><span style="color: #e7c547;">channels</span><span style="color: #b9ca4a; background-color: #000000;">)</span>
<span style="color: #e7c547;">channels</span>
<span style="color: #e7c547; background-color: #000000;">}</span>
<span style="color: #70c0b1; background-color: #000000;">}</span>
<span style="color: #e78c45;">loop</span><span style="color: #70c0b1; background-color: #000000;">(</span><span style="color: #e7c547;">my_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">parent_subject</span><span style="color: #eaeaea; background-color: #000000;">,</span> <span style="color: #e7c547;">new_channels</span><span style="color: #70c0b1; background-color: #000000;">)</span>
<span style="color: #eaeaea; background-color: #000000;">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgcc09aa2" class="outline-3">
<h3 id="orgcc09aa2">The Worker</h3>
<div class="outline-text-3" id="text-orgcc09aa2">
<p>
PUT WORKER EXAMPLE HERE
</p>
</div>
</div>
<div id="outline-container-org640b005" class="outline-3">
<h3 id="org640b005">The supervisor</h3>
<div class="outline-text-3" id="text-org640b005">
<p>
PUT SUPERVISOR EXAMPLE HERE
</p>
</div>
</div>
<div id="outline-container-org442e8b0" class="outline-3">
<h3 id="org442e8b0">Round the ring</h3>
<div class="outline-text-3" id="text-org442e8b0">
<p>
DESCRIBE RING DEMO HERE AND ADD SOURCE.
</p>
<p>
References: gleam otp source for <a href="https://github.com/gleam-lang/otp/blob/main/src/gleam/otp/supervisor.gleam">supervisors</a>.
</p>
</div>
</div>
</div>
<div id="outline-container-orgaddb9ee" class="outline-2">
<h2 id="orgaddb9ee">Distribution</h2>
<div class="outline-text-2" id="text-orgaddb9ee">
<p>
LINK UP EXAMPLE DISTRIBUTION LIBRARY HERE
</p>
</div>
<div id="outline-container-org1a5ab4e" class="outline-3">
<h3 id="org1a5ab4e">Starting up nodes.</h3>
<div class="outline-text-3" id="text-org1a5ab4e">
<p>
Setup example here.
</p>
</div>
</div>
<div id="outline-container-org254266d" class="outline-3">
<h3 id="org254266d">Spawning a process on another node.</h3>
</div>
<div id="outline-container-org1c5581d" class="outline-3">
<h3 id="org1c5581d">Finding processes on another node</h3>
</div>
<div id="outline-container-org80d28a7" class="outline-3">
<h3 id="org80d28a7">Gleam process registry ?</h3>
</div>
</div>
<div id="outline-container-org38b19c8" class="outline-2">
<h2 id="org38b19c8">Resources:</h2>
</div>
</div>
</body>
</html>