@rip-lang/server 1.3.115 → 1.3.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +435 -622
  2. package/api.rip +4 -4
  3. package/control/cli.rip +221 -1
  4. package/control/control.rip +9 -0
  5. package/control/lifecycle.rip +6 -1
  6. package/control/watchers.rip +10 -0
  7. package/control/workers.rip +9 -5
  8. package/default.rip +3 -1
  9. package/docs/READ_VALIDATORS.md +656 -0
  10. package/docs/edge/CONFIG_LIFECYCLE.md +70 -32
  11. package/docs/edge/CONTRACTS.md +60 -69
  12. package/docs/edge/EDGEFILE_CONTRACT.md +258 -29
  13. package/docs/edge/M0B_REVIEW_NOTES.md +5 -5
  14. package/edge/config.rip +584 -52
  15. package/edge/forwarding.rip +6 -2
  16. package/edge/metrics.rip +19 -1
  17. package/edge/registry.rip +29 -3
  18. package/edge/router.rip +138 -0
  19. package/edge/runtime.rip +98 -0
  20. package/edge/static.rip +69 -0
  21. package/edge/tls.rip +23 -0
  22. package/edge/upstream.rip +272 -0
  23. package/edge/verify.rip +73 -0
  24. package/middleware.rip +3 -3
  25. package/package.json +2 -2
  26. package/server.rip +775 -393
  27. package/tests/control.rip +18 -0
  28. package/tests/edgefile.rip +165 -0
  29. package/tests/metrics.rip +16 -0
  30. package/tests/proxy.rip +22 -1
  31. package/tests/registry.rip +27 -0
  32. package/tests/router.rip +101 -0
  33. package/tests/runtime_entrypoints.rip +16 -0
  34. package/tests/servers.rip +262 -0
  35. package/tests/static.rip +64 -0
  36. package/tests/streams_clienthello.rip +108 -0
  37. package/tests/streams_index.rip +53 -0
  38. package/tests/streams_pipe.rip +70 -0
  39. package/tests/streams_router.rip +39 -0
  40. package/tests/streams_runtime.rip +38 -0
  41. package/tests/streams_upstream.rip +34 -0
  42. package/tests/upstream.rip +191 -0
  43. package/tests/verify.rip +148 -0
  44. package/tests/watchers.rip +15 -0
@@ -0,0 +1,148 @@
1
+ import { test, eq, ok } from '../test.rip'
2
+ import { compileRouteTable } from '../edge/router.rip'
3
+ import { collectRouteRequirements, verifyRouteRuntime } from '../edge/verify.rip'
4
+
5
+ test "collectRouteRequirements gathers upstreams and managed apps", ->
6
+ table = compileRouteTable([
7
+ { path: '/api/*', upstream: 'api' }
8
+ { path: '/admin/*', app: 'admin' }
9
+ ])
10
+ appRegistry =
11
+ apps: new Map([
12
+ ['default', { config: { entry: '/srv/index.rip' } }]
13
+ ['reports', { config: { entry: '/srv/reports/index.rip' } }]
14
+ ])
15
+ reqs = collectRouteRequirements(table, appRegistry, 'default')
16
+ eq reqs.upstreamIds, ['api']
17
+ ok reqs.appIds.includes('admin')
18
+ ok reqs.appIds.includes('reports')
19
+
20
+ test "verifyRouteRuntime returns upstream reason code", ->
21
+ runtime =
22
+ upstreamPool:
23
+ upstreams: new Map([
24
+ ['api', { id: 'api', targets: [{ targetId: 'api:0' }, { targetId: 'api:1' }] }]
25
+ ])
26
+ routeTable: compileRouteTable([{ path: '/api/*', upstream: 'api' }])
27
+ appRegistry = { apps: new Map() }
28
+ result = verifyRouteRuntime(
29
+ runtime,
30
+ appRegistry,
31
+ 'default',
32
+ ((pool, id) -> pool.upstreams.get(id)),
33
+ ((pool, target) -> false),
34
+ ((registry, appId) -> registry.apps.get(appId))
35
+ )
36
+ eq result.ok, false
37
+ eq result.code, 'upstream_no_healthy_targets'
38
+ eq result.details.upstreamId, 'api'
39
+ eq result.details.requiredHealthyTargets, 1
40
+
41
+ test "verifyRouteRuntime returns app worker reason code", ->
42
+ runtime =
43
+ upstreamPool:
44
+ upstreams: new Map()
45
+ routeTable: compileRouteTable([{ path: '/admin/*', app: 'admin' }])
46
+ appRegistry =
47
+ apps: new Map([
48
+ ['admin', { sockets: [], config: { entry: '/srv/admin/index.rip' } }]
49
+ ])
50
+ result = verifyRouteRuntime(
51
+ runtime,
52
+ appRegistry,
53
+ 'default',
54
+ ((pool, id) -> pool.upstreams.get(id)),
55
+ ((pool, target) -> true),
56
+ ((registry, appId) -> registry.apps.get(appId))
57
+ )
58
+ eq result.ok, false
59
+ eq result.code, 'app_no_ready_workers'
60
+ eq result.details.appId, 'admin'
61
+
62
+ test "verifyRouteRuntime succeeds when referenced upstreams and apps are healthy", ->
63
+ runtime =
64
+ upstreamPool:
65
+ upstreams: new Map([
66
+ ['api', { id: 'api', targets: [{ targetId: 'api:0' }] }]
67
+ ])
68
+ routeTable: compileRouteTable([
69
+ { path: '/api/*', upstream: 'api' }
70
+ { path: '/admin/*', app: 'admin' }
71
+ ])
72
+ appRegistry =
73
+ apps: new Map([
74
+ ['admin', { sockets: [{ socket: '/tmp/a.sock' }], config: { entry: '/srv/admin/index.rip' } }]
75
+ ])
76
+ result = verifyRouteRuntime(
77
+ runtime,
78
+ appRegistry,
79
+ 'default',
80
+ ((pool, id) -> pool.upstreams.get(id)),
81
+ ((pool, target) -> true),
82
+ ((registry, appId) -> registry.apps.get(appId))
83
+ )
84
+ eq result.ok, true
85
+ eq result.code, null
86
+
87
+ test "verifyRouteRuntime honors minimum healthy targets policy", ->
88
+ runtime =
89
+ upstreamPool:
90
+ upstreams: new Map([
91
+ ['api', { id: 'api', targets: [{ targetId: 'api:0' }, { targetId: 'api:1' }] }]
92
+ ])
93
+ routeTable: compileRouteTable([{ path: '/api/*', upstream: 'api' }])
94
+ appRegistry = { apps: new Map() }
95
+ healthyCount = 0
96
+ result = verifyRouteRuntime(
97
+ runtime,
98
+ appRegistry,
99
+ 'default',
100
+ ((pool, id) -> pool.upstreams.get(id)),
101
+ ((pool, target) ->
102
+ healthyCount++
103
+ healthyCount is 1
104
+ ),
105
+ ((registry, appId) -> registry.apps.get(appId)),
106
+ minHealthyTargetsPerUpstream: 2
107
+ )
108
+ eq result.ok, false
109
+ eq result.code, 'upstream_no_healthy_targets'
110
+ eq result.details.healthyTargets, 1
111
+ eq result.details.requiredHealthyTargets, 2
112
+
113
+ test "verifyRouteRuntime can skip healthy upstream checks", ->
114
+ runtime =
115
+ upstreamPool:
116
+ upstreams: new Map()
117
+ routeTable: compileRouteTable([{ path: '/api/*', upstream: 'api' }])
118
+ appRegistry = { apps: new Map() }
119
+ result = verifyRouteRuntime(
120
+ runtime,
121
+ appRegistry,
122
+ 'default',
123
+ ((pool, id) -> pool.upstreams.get(id)),
124
+ ((pool, target) -> false),
125
+ ((registry, appId) -> registry.apps.get(appId)),
126
+ requireHealthyUpstreams: false
127
+ )
128
+ eq result.ok, true
129
+
130
+ test "verifyRouteRuntime can skip unrouted managed apps", ->
131
+ runtime =
132
+ upstreamPool:
133
+ upstreams: new Map()
134
+ routeTable: compileRouteTable([])
135
+ appRegistry =
136
+ apps: new Map([
137
+ ['reports', { sockets: [], config: { entry: '/srv/reports/index.rip' } }]
138
+ ])
139
+ result = verifyRouteRuntime(
140
+ runtime,
141
+ appRegistry,
142
+ 'default',
143
+ ((pool, id) -> pool.upstreams.get(id)),
144
+ ((pool, target) -> true),
145
+ ((registry, appId) -> registry.apps.get(appId)),
146
+ includeUnroutedManagedApps: false
147
+ )
148
+ eq result.ok, true
@@ -0,0 +1,15 @@
1
+ import { test, eq } from '../test.rip'
2
+ import { shouldTriggerCodeReload } from '../control/watchers.rip'
3
+
4
+ test "shouldTriggerCodeReload matches extension watch specs", ->
5
+ eq shouldTriggerCodeReload('foo.rip', '*.rip'), true
6
+ eq shouldTriggerCodeReload('foo.txt', '*.rip'), false
7
+
8
+ test "shouldTriggerCodeReload matches exact filenames", ->
9
+ eq shouldTriggerCodeReload('config.rip', 'config.rip'), true
10
+ eq shouldTriggerCodeReload('nested/config.rip', 'config.rip'), true
11
+ eq shouldTriggerCodeReload('other.rip', 'config.rip'), false
12
+
13
+ test "shouldTriggerCodeReload ignores the entry file itself", ->
14
+ eq shouldTriggerCodeReload('index.rip', '*.rip', 'index.rip'), false
15
+ eq shouldTriggerCodeReload('nested.rip', '*.rip', 'index.rip'), true