Diffinery

homeflare/celldpublic

celld/docs/services/durable-objects-flow.svg
127 lines · 8.0 KBRaw History
1<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 440 520" role="img" aria-labelledby="doFlowTitle doFlowDesc">
2 <title id="doFlowTitle">One name reaches one cell, and one node owns that cell</title>
3 <desc id="doFlowDesc">Workers on node A and node B both address the name room-7,
4and a Worker on node C addresses the name room-8. getByName turns each name into
5one 64-digit hexadecimal id, the owner record in the fleet bucket names one
6owner node for each cell, and celld forwards the call to that node. The room-7
7cell has owner node B and epoch e7, and the room-8 cell has owner node C and
8epoch e3, so ownership belongs to a cell and not to a class. Each cell runs one
9event at a time. The room-7 cell keeps its own SQLite database on node B. Node B
10sends each write to a follower node, whose fsync releases the answer, and the
11write then uploads to the fleet bucket under cells/room-7/ltx/e7/. The previous
12prefix, cells/room-7/ltx/e6/, is superseded, so a node that lost the cell cannot
13damage the current data. Node C keeps the room-8 cell the same way, under its
14own epoch.</desc>
15 <style>
16 .d-ink { color: #121212 }
17 .d-soft { color: #3d3b37 }
18 .d-faint { color: #6e6a62 }
19 .d-acc { color: #10803f }
20 .d-panel { color: #ffffff }
21 .d-sunk { color: #f0eee8 }
22 .d-tint { color: #d6efdf }
23 text {
24 font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
25 font-size: 13px;
26 fill: currentColor;
27 }
28 @media (prefers-color-scheme: dark) {
29 .d-ink { color: #efede7 }
30 .d-soft { color: #c9c6be }
31 .d-faint { color: #928e85 }
32 .d-acc { color: #3fc472 }
33 .d-panel { color: #1a1a19 }
34 .d-sunk { color: #232321 }
35 .d-tint { color: #10301d }
36 }
37 </style>
38 <defs>
39 <marker id="do-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6"
40 markerHeight="6" orient="auto-start-reverse">
41 <path class="d-soft" fill="currentColor" d="M0 0 L10 5 L0 10 z" />
42 </marker>
43 </defs>
44
45 <!-- Callers: three nodes, two of them addressing one name. -->
46 <rect class="d-panel" fill="currentColor" x="6" y="8" width="136" height="48" rx="6" />
47 <rect class="d-soft" fill="none" stroke="currentColor" x="6" y="8" width="136" height="48" rx="6" />
48 <text class="d-ink" fill="currentColor" x="74" y="29" text-anchor="middle">Worker · node A</text>
49 <text class="d-soft" fill="currentColor" x="74" y="46" text-anchor="middle">name: "room-7"</text>
50
51 <rect class="d-panel" fill="currentColor" x="152" y="8" width="136" height="48" rx="6" />
52 <rect class="d-soft" fill="none" stroke="currentColor" x="152" y="8" width="136" height="48" rx="6" />
53 <text class="d-ink" fill="currentColor" x="220" y="29" text-anchor="middle">Worker · node B</text>
54 <text class="d-soft" fill="currentColor" x="220" y="46" text-anchor="middle">name: "room-7"</text>
55
56 <rect class="d-panel" fill="currentColor" x="298" y="8" width="136" height="48" rx="6" />
57 <rect class="d-soft" fill="none" stroke="currentColor" x="298" y="8" width="136" height="48" rx="6" />
58 <text class="d-ink" fill="currentColor" x="366" y="29" text-anchor="middle">Worker · node C</text>
59 <text class="d-soft" fill="currentColor" x="366" y="46" text-anchor="middle">name: "room-8"</text>
60
61 <!-- The boundary each call crosses: name to id, owner record, forward. -->
62 <rect class="d-faint" fill="none" stroke="currentColor" stroke-dasharray="5 4"
63 x="6" y="72" width="428" height="62" rx="6" />
64 <text class="d-faint" fill="currentColor" x="220" y="92" text-anchor="middle">getByName() gives one 64-hex id</text>
65 <text class="d-faint" fill="currentColor" x="220" y="111" text-anchor="middle">the owner record in the bucket names one node</text>
66 <text class="d-faint" fill="currentColor" x="220" y="130" text-anchor="middle">celld forwards the call to that node</text>
67
68 <!-- Two callers of one name join. A second name is a second cell. -->
69 <g class="d-soft" fill="none" stroke="currentColor" stroke-width="1.5">
70 <path d="M74 56 V66" />
71 <path d="M220 56 V66" />
72 <path d="M60 66 H220" />
73 <path d="M60 66 V152" marker-end="url(#do-arrow)" />
74 <path d="M366 56 V66 H380 V152" marker-end="url(#do-arrow)" />
75 </g>
76
77 <!-- One cell, one owner, one event. Ownership belongs to a cell, not a class. -->
78 <rect class="d-tint" fill="currentColor" x="16" y="156" width="200" height="90" rx="6" />
79 <rect class="d-acc" fill="none" stroke="currentColor" stroke-width="2" x="16" y="156" width="200" height="90" rx="6" />
80 <text class="d-ink" fill="currentColor" x="116" y="177" text-anchor="middle">room-7 cell</text>
81 <text class="d-soft" fill="currentColor" x="116" y="196" text-anchor="middle">owner: node B</text>
82 <text class="d-soft" fill="currentColor" x="116" y="215" text-anchor="middle">one event at a time</text>
83 <text class="d-faint" fill="currentColor" x="116" y="234" text-anchor="middle">epoch e7</text>
84
85 <rect class="d-tint" fill="currentColor" x="224" y="156" width="200" height="90" rx="6" />
86 <rect class="d-acc" fill="none" stroke="currentColor" stroke-width="2" x="224" y="156" width="200" height="90" rx="6" />
87 <text class="d-ink" fill="currentColor" x="324" y="177" text-anchor="middle">room-8 cell</text>
88 <text class="d-soft" fill="currentColor" x="324" y="196" text-anchor="middle">owner: node C</text>
89 <text class="d-soft" fill="currentColor" x="324" y="215" text-anchor="middle">one event at a time</text>
90 <text class="d-faint" fill="currentColor" x="324" y="234" text-anchor="middle">epoch e3</text>
91
92 <!-- The owner holds the database, and the write then buys its durability. -->
93 <g class="d-soft" fill="none" stroke="currentColor" stroke-width="1.5">
94 <path d="M116 246 V272" marker-end="url(#do-arrow)" />
95 <path d="M116 322 V346" marker-end="url(#do-arrow)" />
96 <path d="M116 396 V420" marker-end="url(#do-arrow)" />
97 </g>
98
99 <rect class="d-sunk" fill="currentColor" x="16" y="276" width="200" height="46" rx="6" />
100 <rect class="d-soft" fill="none" stroke="currentColor" x="16" y="276" width="200" height="46" rx="6" />
101 <text class="d-ink" fill="currentColor" x="116" y="297" text-anchor="middle">SQLite on node B</text>
102 <text class="d-soft" fill="currentColor" x="116" y="314" text-anchor="middle">one database per cell</text>
103
104 <rect class="d-sunk" fill="currentColor" x="16" y="350" width="200" height="46" rx="6" />
105 <rect class="d-soft" fill="none" stroke="currentColor" x="16" y="350" width="200" height="46" rx="6" />
106 <text class="d-ink" fill="currentColor" x="116" y="371" text-anchor="middle">a follower node</text>
107 <text class="d-soft" fill="currentColor" x="116" y="388" text-anchor="middle">fsync frees the answer</text>
108
109 <text class="d-faint" fill="currentColor" x="326" y="297" text-anchor="middle">node C keeps room-8</text>
110 <text class="d-faint" fill="currentColor" x="326" y="316" text-anchor="middle">the same way, under</text>
111 <text class="d-faint" fill="currentColor" x="326" y="335" text-anchor="middle">its own epoch</text>
112
113 <!-- The epoch in the prefix is the fence. -->
114 <rect class="d-sunk" fill="currentColor" x="6" y="424" width="428" height="90" rx="6" />
115 <rect class="d-soft" fill="none" stroke="currentColor" x="6" y="424" width="428" height="90" rx="6" />
116 <text class="d-ink" fill="currentColor" x="220" y="444" text-anchor="middle">fleet bucket · the long-term copy</text>
117
118 <rect class="d-tint" fill="currentColor" x="18" y="454" width="200" height="48" rx="6" />
119 <rect class="d-acc" fill="none" stroke="currentColor" stroke-width="2" x="18" y="454" width="200" height="48" rx="6" />
120 <text class="d-ink" fill="currentColor" x="118" y="474" text-anchor="middle">cells/room-7/ltx/e7/</text>
121 <text class="d-soft" fill="currentColor" x="118" y="492" text-anchor="middle">this owner writes here</text>
122
123 <rect class="d-faint" fill="none" stroke="currentColor" stroke-dasharray="5 4"
124 x="222" y="454" width="200" height="48" rx="6" />
125 <text class="d-faint" fill="currentColor" x="322" y="474" text-anchor="middle">cells/room-7/ltx/e6/</text>
126 <text class="d-faint" fill="currentColor" x="322" y="492" text-anchor="middle">an old owner is fenced</text>
127</svg>