Explain Endor concepts with a reproducible multi-region topology
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 4m14s
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 4m14s
This commit is contained in:
@@ -0,0 +1,238 @@
|
||||
"""Endor concept topology: explicit meshes, storage dependencies and recovery paths."""
|
||||
from pathlib import Path
|
||||
import drawsvg as d
|
||||
|
||||
INK = '#233b38'
|
||||
GREEN = '#2d8b77'
|
||||
BLUE = '#467fb4'
|
||||
PURPLE = '#8a6ab4'
|
||||
AMBER = '#b58b47'
|
||||
MUTED = '#6d817c'
|
||||
LINE = '#dce8e3'
|
||||
FONT = 'ui-sans-serif, system-ui, -apple-system, PingFang SC, Microsoft YaHei, sans-serif'
|
||||
|
||||
|
||||
def build_architecture(output: Path) -> None:
|
||||
svg = d.Drawing(1760, 1640)
|
||||
svg.append_title('Endor 概念架构草案:全球入口、区域网关与运行时、分片和跨区恢复')
|
||||
svg.append(d.Rectangle(0, 0, 1760, 1640, fill='#fcfdfb'))
|
||||
|
||||
def rect(x, y, w, h, fill='white', stroke=LINE, radius=12, dash=None):
|
||||
svg.append(d.Rectangle(x, y, w, h, rx=radius, fill=fill, stroke=stroke,
|
||||
stroke_width=1.2, stroke_dasharray=dash))
|
||||
|
||||
def text(s, x, y, size=16, color=INK, weight='400', anchor='start'):
|
||||
svg.append(d.Text(s, size, x, y, fill=color, font_family=FONT,
|
||||
font_weight=weight, text_anchor=anchor))
|
||||
|
||||
def path(points, color=GREEN, dash=None, width=1.6, arrow=False, opacity=1):
|
||||
p = d.Path(fill='none', stroke=color, stroke_width=width,
|
||||
stroke_dasharray=dash, stroke_linecap='round',
|
||||
stroke_linejoin='round', opacity=opacity)
|
||||
p.M(*points[0])
|
||||
for pt in points[1:]:
|
||||
p.L(*pt)
|
||||
svg.append(p)
|
||||
if arrow:
|
||||
x, y = points[-1]
|
||||
px, py = points[-2]
|
||||
import math
|
||||
angle = math.atan2(y-py, x-px)
|
||||
a = d.Path(fill='none', stroke=color, stroke_width=width,
|
||||
stroke_linecap='round', opacity=opacity)
|
||||
for sign in [-1, 1]:
|
||||
a.M(x-7*math.cos(angle+sign*.48), y-7*math.sin(angle+sign*.48)).L(x, y)
|
||||
svg.append(a)
|
||||
|
||||
def dot(x, y, color=GREEN, r=3):
|
||||
svg.append(d.Circle(x, y, r, fill='#fcfdfb', stroke=color, stroke_width=1.5))
|
||||
|
||||
def icon(kind, x, y, color=GREEN, scale=1):
|
||||
# Icons are vector geometry rather than font glyphs or downloaded artwork.
|
||||
g = d.Group(transform=f'translate({x},{y}) scale({scale})',
|
||||
stroke=color, stroke_width=1.8, fill='none',
|
||||
stroke_linecap='round', stroke_linejoin='round')
|
||||
if kind == 'globe':
|
||||
g.append(d.Circle(0, 0, 23)); g.append(d.Ellipse(0, 0, 10, 23))
|
||||
g.append(d.Line(-22, -8, 22, -8)); g.append(d.Line(-22, 8, 22, 8))
|
||||
elif kind == 'client':
|
||||
g.append(d.Rectangle(-26,-20,52,33,rx=4)); g.append(d.Line(-32,21,32,21))
|
||||
g.append(d.Lines(-26,13,-32,21,32,21,26,13))
|
||||
g.append(d.Line(-6,17,6,17))
|
||||
elif kind == 'edge':
|
||||
g.append(d.Circle(0,0,24)); g.append(d.Lines(-10,-6,0,-14,11,-6,0,2,-10,-6))
|
||||
g.append(d.Lines(-10,3,0,11,11,3)); g.append(d.Lines(-10,11,0,19,11,11))
|
||||
elif kind == 'shield':
|
||||
g.append(d.Path().M(0,-25).L(22,-16).L(20,5).Q(17,19,0,27).Q(-17,19,-20,5).L(-22,-16).Z())
|
||||
g.append(d.Lines(-9,0,-2,7,11,-7))
|
||||
elif kind == 'lb':
|
||||
g.append(d.Circle(0,-17,7)); g.append(d.Circle(-22,19,7)); g.append(d.Circle(22,19,7))
|
||||
g.append(d.Lines(0,-10,0,1,-22,1,-22,12)); g.append(d.Lines(0,1,22,1,22,12))
|
||||
elif kind in ('gateway','runtime'):
|
||||
for dy in [-14,2]:
|
||||
g.append(d.Rectangle(-25,dy,50,12,rx=3))
|
||||
g.append(d.Circle(-16,dy+6,1.3,fill=color)); g.append(d.Line(-8,dy+6,16,dy+6))
|
||||
if kind == 'runtime':
|
||||
g.append(d.Line(-13,20,13,20)); g.append(d.Line(0,14,0,20))
|
||||
elif kind == 'vm':
|
||||
g.append(d.Rectangle(-17,-13,34,26,rx=4))
|
||||
for a in [-10,0,10]:
|
||||
g.append(d.Line(a,-18,a,-13)); g.append(d.Line(a,13,a,18))
|
||||
for a in [-6,6]:
|
||||
g.append(d.Line(-22,a,-17,a)); g.append(d.Line(17,a,22,a))
|
||||
g.append(d.Path().M(-6,-5).L(0,0).L(-6,5)); g.append(d.Line(4,6,10,6))
|
||||
elif kind == 'db':
|
||||
g.append(d.Path().M(-21,-12).L(-21,15).C(-21,27,21,27,21,15).L(21,-12))
|
||||
g.append(d.Ellipse(0,-12,21,8)); g.append(d.Path().M(-21,1).C(-21,12,21,12,21,1))
|
||||
elif kind == 'pool':
|
||||
for dx,dy in [(-12,-9),(12,-9),(0,12)]:
|
||||
g.append(d.Rectangle(dx-11,dy-10,22,20,rx=5))
|
||||
g.append(d.Circle(dx,dy,3,fill=color,stroke='none'))
|
||||
elif kind == 'bucket':
|
||||
g.append(d.Ellipse(0,-15,23,7)); g.append(d.Lines(-23,-15,-18,21,18,21,23,-15))
|
||||
g.append(d.Path().M(-17,6).Q(0,17,17,6))
|
||||
elif kind == 'backup':
|
||||
g.append(d.Rectangle(-25,-15,50,36,rx=4)); g.append(d.Line(-29,-15,29,-15))
|
||||
g.append(d.Lines(-6,5,0,-2,6,5)); g.append(d.Line(0,-2,0,14))
|
||||
svg.append(g)
|
||||
|
||||
def badge(s, x, y, color=GREEN, bg='#edf5ee', w=118):
|
||||
rect(x, y-17, w, 25, bg, 'none', 5)
|
||||
text(s, x+w/2, y, 12, color, '500', 'middle')
|
||||
|
||||
text('ENDOR / SYSTEM ATLAS', 45, 48, 13, GREEN, '600')
|
||||
text('一个全球入口,多个区域,一组可恢复的对象。', 45, 92, 31, INK, '600')
|
||||
badge('概念设计 · 草案', 1520, 57, AMBER, '#f8f2e6', 192)
|
||||
text('01 全球接入', 45, 142, 13, MUTED, '600')
|
||||
|
||||
# Request routes first, icons and labels above them.
|
||||
path([(170,214),(500,214)], arrow=True)
|
||||
text('动态 API / 对象访问', 280, 201, 13, GREEN)
|
||||
path([(120,185),(120,163),(1160,163),(1160,184)], BLUE, arrow=True)
|
||||
text('静态资源 / 可缓存内容', 815, 155, 13, BLUE)
|
||||
path([(110,250),(110,300),(1540,300),(1540,253)], PURPLE, '5 6', arrow=True)
|
||||
text('登录 / 换取凭证', 1140, 290, 13, PURPLE)
|
||||
icon('client',120,214)
|
||||
text('全球客户端',120,268,17,INK,'600','middle')
|
||||
icon('globe',550,214)
|
||||
text('endorphin API',620,208,23,INK,'600')
|
||||
text('全球流量入口 · 按健康与策略选区',620,237,14,MUTED)
|
||||
icon('edge',1160,214,BLUE)
|
||||
text('CDN',1200,208,21,INK,'600')
|
||||
text('命中直接返回',1200,234,13,MUTED)
|
||||
icon('shield',1540,214,PURPLE)
|
||||
text('身份服务',1580,207,17,INK,'600')
|
||||
text('登录 / 签发凭证',1580,232,12,MUTED)
|
||||
text('独立控制服务 · 建议',1580,256,11,PURPLE)
|
||||
|
||||
# Two equally detailed regions. Solid edges mean eligible request routes,
|
||||
# not broadcast execution or a requirement for inter-runtime mesh links.
|
||||
regions = [('北美', 'NA', 40, GREEN), ('亚洲', 'AS', 910, BLUE)]
|
||||
for name, prefix, ox, accent in regions:
|
||||
center = ox+390
|
||||
rect(ox,337,780,815,'#ffffff',LINE,18)
|
||||
text(f'{name}区域',ox+28,375,23,INK,'600')
|
||||
text(f'{prefix} / 独立故障域',ox+28,401,12,MUTED)
|
||||
badge('区域入口',ox+623,376,accent,'#f0f6f3',126)
|
||||
# Region's own load balancer; global routing fans into these, not nodes.
|
||||
path([(800,252),(800,318),(center,318),(center,419)], GREEN, arrow=True)
|
||||
icon('lb',center,446,accent,.72)
|
||||
text('区域负载均衡',center+42,442,16,INK,'600')
|
||||
text('健康检查 / TLS 路由',center+42,464,12,MUTED)
|
||||
gateways = [ox+235, ox+545]
|
||||
runtime_x = [ox+135, ox+390, ox+645]
|
||||
for gx in gateways:
|
||||
path([(center,470),(center,488),(gx,488),(gx,514)],accent,arrow=True)
|
||||
text('TRAEFIK',ox+27,528,12,MUTED,'600')
|
||||
text('生产冗余 · 可选',ox+27,550,12,MUTED)
|
||||
for gi,gx in enumerate(gateways):
|
||||
icon('gateway',gx,536,accent,.9)
|
||||
text(f'Traefik {gi+1}',gx,579,14,INK,'500','middle')
|
||||
if gi == 1:
|
||||
badge('HA 副本',gx+42,539,accent,'#edf5f0',78)
|
||||
# Explicit K2,3 complete bipartite graph. Every edge is drawn.
|
||||
for gx in gateways:
|
||||
for nx in runtime_x:
|
||||
path([(gx,592),(nx,665)],accent,width=1.35,opacity=.65)
|
||||
dot(gx,592,accent)
|
||||
for ni,nx in enumerate(runtime_x):
|
||||
dot(nx,665,accent)
|
||||
icon('runtime',nx,701,accent)
|
||||
text(f'Nexus Runtime {ni+1}',nx,746,15,INK,'600','middle')
|
||||
icon('vm',nx-49,779,accent,.65)
|
||||
text('Aster VM',nx-21,785,14,INK)
|
||||
text('1 Nexus : 1 VM',nx,813,11,MUTED,'400','middle')
|
||||
text('K₂,₃ 全连接',ox+22,621,11,accent)
|
||||
text('选择健康节点',ox+22,640,11,MUTED)
|
||||
# Shared regional shard routing bus, not a fixed node-to-shard assignment.
|
||||
for nx in runtime_x:
|
||||
path([(nx,829),(nx,850)],accent,opacity=.8)
|
||||
path([(runtime_x[0],850),(runtime_x[-1],850)],accent,opacity=.8)
|
||||
text('分片定位 / 对象读写',center,874,12,MUTED,'400','middle')
|
||||
for si,sx in enumerate([ox+24,ox+406]):
|
||||
mid=sx+175
|
||||
path([(mid,850),(mid,905)],accent,arrow=True)
|
||||
rect(sx,912,350,208,'#f8faf7', '#e2eae1',10)
|
||||
text(f'{prefix}-{si+1:02} / 数据分片',sx+15,939,14,INK,'600')
|
||||
badge('主 + 区域 HA',sx+212,938,accent,'#edf3ec',124)
|
||||
for kind,dx,label in [('db',62,'PostgreSQL'),('pool',175,'Aerarium'),('bucket',288,'S3')]:
|
||||
icon(kind,sx+dx,989,accent,.8)
|
||||
text(label,sx+dx,1033,13,INK,'500','middle')
|
||||
# Every tier has an explicit local standby, linked by dots.
|
||||
path([(sx+dx,1041),(sx+dx,1062)],accent,'2 4',width=1.1)
|
||||
icon(kind,sx+dx,1080,accent,.38)
|
||||
# Aerarium depends on both PostgreSQL and S3.
|
||||
path([(sx+150,986),(sx+87,986)],accent,arrow=True)
|
||||
path([(sx+200,986),(sx+263,986)],accent,arrow=True)
|
||||
text('Object data pool',mid,1052,10,MUTED,'400','middle')
|
||||
text('区域内副本 · 跨故障域放置',mid,1108,11,MUTED,'400','middle')
|
||||
# Each shard gets its own, separately routed off-region copy.
|
||||
dot(mid,1120,AMBER)
|
||||
|
||||
|
||||
# Cross-region origin fill. CDN is intentionally outside private dynamic API.
|
||||
path([(1160,253),(1160,278),(1718,278),(1718,883),(1680,883),(1680,989),(1627,989)],BLUE,'2 6',arrow=True)
|
||||
rect(1698,582,58,46,'#fcfdfb','none',4)
|
||||
text('CDN',1727,600,12,BLUE,anchor='middle')
|
||||
text('S3 回源',1727,621,11,MUTED,anchor='middle')
|
||||
# Control-plane key retrieval, deliberately not a runtime hosting dependency.
|
||||
path([(1540,245),(1540,309),(869,309),(869,705)],PURPLE,'5 6',arrow=True)
|
||||
path([(869,705),(710,705)],PURPLE,'5 6',arrow=True)
|
||||
path([(869,705),(1020,705)],PURPLE,'5 6',arrow=True)
|
||||
rect(791,682,156,39,'#fcfdfb','none',4)
|
||||
text('JWKS / 凭证验证',869,699,12,PURPLE,anchor='middle')
|
||||
text('Nexus 本地验证',869,716,11,PURPLE,anchor='middle')
|
||||
|
||||
text('02 跨区域恢复层',45,1486,16,INK,'600')
|
||||
text('每个源分片都有一个异地目标;正常读取优先本区域,故障时恢复或转至已追平的副本。',45,1514,14,MUTED)
|
||||
# Source routes are independent, with a visible crossing gap at the center.
|
||||
# Backups physically hosted in the opposite region are explicitly labeled.
|
||||
backup_specs = [
|
||||
('亚洲分片的异地备份 · 位于北美', 40, 'AS', [1109,1491], [239,621]),
|
||||
('北美分片的异地备份 · 位于亚洲', 910, 'NA', [239,621], [1109,1491]),
|
||||
]
|
||||
for bi, (label, bx, source, sources, targets) in enumerate(backup_specs):
|
||||
rect(bx,1280,780,174,'#fbf8f1','#e9dec8',14)
|
||||
text(label,bx+25,1310,17,INK,'600')
|
||||
for i,(origin,target) in enumerate(zip(sources,targets)):
|
||||
lane=1180+bi*40+i*20
|
||||
path([(origin,1120),(origin+12,1134),(origin+12,lane),(target-12,lane),(target-12,1280)],AMBER,'6 6',arrow=True)
|
||||
icon('backup',target-77,1376,AMBER,.85)
|
||||
text(f'{source}-{i+1:02} 备份集',target-38,1369,15,INK,'600')
|
||||
text('PG + Aerarium + S3',target-38,1393,12,MUTED)
|
||||
text('恢复点 / 清单校验 / 重试',target-38,1415,11,MUTED)
|
||||
# A caption is painted over empty whitespace, no connectivity is implied.
|
||||
rect(724,1148,312,25,'#fcfdfb','none',4)
|
||||
text('异步复制 / 版本化备份',880,1166,13,AMBER,'500','middle')
|
||||
path([(50,1555),(105,1555)],GREEN,arrow=True)
|
||||
text('请求与数据依赖',118,1560,12,MUTED)
|
||||
path([(355,1555),(410,1555)],PURPLE,'5 6')
|
||||
text('身份控制 / 公钥',423,1560,12,MUTED)
|
||||
path([(670,1555),(725,1555)],BLUE,'2 6')
|
||||
text('缓存回源',738,1560,12,MUTED)
|
||||
path([(950,1555),(1005,1555)],AMBER,'6 6')
|
||||
text('跨区复制 / 备份',1018,1560,12,MUTED)
|
||||
text('示意数量:2 区域 × 2 网关 × 3 Runtime × 2 分片;数量不构成部署要求。',45,1608,12,MUTED)
|
||||
text('可恢复性以已持久化且已校验的恢复点为边界;异步 ≠ 零 RPO。',1715,1608,12,AMBER,anchor='end')
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
svg.save_svg(str(output))
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Generate local SVG assets without external fonts or rendering services."""
|
||||
from pathlib import Path
|
||||
import drawsvg as draw
|
||||
from .architecture import build_architecture
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -32,3 +33,6 @@ def main() -> None:
|
||||
stroke="#0f766e", stroke_width=2))
|
||||
diagram.save_svg(str(output))
|
||||
print(f"Generated {output.relative_to(root)}")
|
||||
topology = output.parent / "endor-architecture.svg"
|
||||
build_architecture(topology)
|
||||
print(f"Generated {topology.relative_to(root)}")
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Protect the relationships that make this a topology rather than a block chart."""
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from endor_figures.architecture import build_architecture
|
||||
|
||||
|
||||
class ArchitectureTest(unittest.TestCase):
|
||||
def test_topology_and_reproducibility(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
first, second = (Path(directory) / name for name in ('first.svg', 'second.svg'))
|
||||
build_architecture(first)
|
||||
build_architecture(second)
|
||||
self.assertEqual(first.read_bytes(), second.read_bytes())
|
||||
root = ET.parse(first).getroot()
|
||||
ns = {'s': 'http://www.w3.org/2000/svg'}
|
||||
texts = [''.join(e.itertext()) for e in root.findall('.//s:text', ns)]
|
||||
self.assertEqual(texts.count('Aster VM'), 6)
|
||||
for i in range(1, 4):
|
||||
self.assertEqual(texts.count(f'Nexus Runtime {i}'), 2)
|
||||
for i in range(1, 3):
|
||||
self.assertEqual(texts.count(f'Traefik {i}'), 2)
|
||||
for prefix in ('NA', 'AS'):
|
||||
for i in range(1, 3):
|
||||
self.assertIn(f'{prefix}-{i:02} / 数据分片', texts)
|
||||
self.assertIn(f'{prefix}-{i:02} 备份集', texts)
|
||||
mesh_edges = [e for e in root.findall('.//s:path', ns)
|
||||
if e.get('stroke-width') == '1.35' and e.get('opacity') == '0.65']
|
||||
self.assertEqual(len(mesh_edges), 12, 'Each region must retain the full K2,3 mesh')
|
||||
# The figure must remain self-contained and editable.
|
||||
self.assertEqual(root.findall('.//s:image', ns), [])
|
||||
self.assertIn('异步复制 / 版本化备份', texts)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user