@alchemy.run/effect-cluster 0.0.0-stage → 2.0.0-beta.86
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.
- package/LICENSE +201 -0
- package/README.md +105 -2
- package/lib/AWS/Database.d.ts +54 -0
- package/lib/AWS/Database.d.ts.map +1 -0
- package/lib/AWS/Database.js +96 -0
- package/lib/AWS/Database.js.map +1 -0
- package/lib/AWS/EcsPool.d.ts +56 -0
- package/lib/AWS/EcsPool.d.ts.map +1 -0
- package/lib/AWS/EcsPool.js +87 -0
- package/lib/AWS/EcsPool.js.map +1 -0
- package/lib/AWS/index.d.ts +7 -0
- package/lib/AWS/index.d.ts.map +1 -0
- package/lib/AWS/index.js +7 -0
- package/lib/AWS/index.js.map +1 -0
- package/lib/AWS/internal/Gateway.d.ts +23 -0
- package/lib/AWS/internal/Gateway.d.ts.map +1 -0
- package/lib/AWS/internal/Gateway.js +70 -0
- package/lib/AWS/internal/Gateway.js.map +1 -0
- package/lib/Cloudflare/DurableObjectPool.d.ts +42 -0
- package/lib/Cloudflare/DurableObjectPool.d.ts.map +1 -0
- package/lib/Cloudflare/DurableObjectPool.js +136 -0
- package/lib/Cloudflare/DurableObjectPool.js.map +1 -0
- package/lib/Cloudflare/PoolWorker.d.ts +186 -0
- package/lib/Cloudflare/PoolWorker.d.ts.map +1 -0
- package/lib/Cloudflare/PoolWorker.js +75 -0
- package/lib/Cloudflare/PoolWorker.js.map +1 -0
- package/lib/Cloudflare/index.d.ts +7 -0
- package/lib/Cloudflare/index.d.ts.map +1 -0
- package/lib/Cloudflare/index.js +7 -0
- package/lib/Cloudflare/index.js.map +1 -0
- package/lib/Cloudflare/internal/Objects.d.ts +38 -0
- package/lib/Cloudflare/internal/Objects.d.ts.map +1 -0
- package/lib/Cloudflare/internal/Objects.js +102 -0
- package/lib/Cloudflare/internal/Objects.js.map +1 -0
- package/lib/Cron.d.ts +143 -0
- package/lib/Cron.d.ts.map +1 -0
- package/lib/Cron.js +83 -0
- package/lib/Cron.js.map +1 -0
- package/lib/Database.d.ts +95 -0
- package/lib/Database.d.ts.map +1 -0
- package/lib/Database.js +38 -0
- package/lib/Database.js.map +1 -0
- package/lib/Docker/Database.d.ts +42 -0
- package/lib/Docker/Database.d.ts.map +1 -0
- package/lib/Docker/Database.js +53 -0
- package/lib/Docker/Database.js.map +1 -0
- package/lib/Docker/SwarmPool.d.ts +44 -0
- package/lib/Docker/SwarmPool.d.ts.map +1 -0
- package/lib/Docker/SwarmPool.js +56 -0
- package/lib/Docker/SwarmPool.js.map +1 -0
- package/lib/Docker/index.d.ts +7 -0
- package/lib/Docker/index.d.ts.map +1 -0
- package/lib/Docker/index.js +7 -0
- package/lib/Docker/index.js.map +1 -0
- package/lib/Entity.d.ts +348 -0
- package/lib/Entity.d.ts.map +1 -0
- package/lib/Entity.js +308 -0
- package/lib/Entity.js.map +1 -0
- package/lib/Fly/Database.d.ts +50 -0
- package/lib/Fly/Database.d.ts.map +1 -0
- package/lib/Fly/Database.js +56 -0
- package/lib/Fly/Database.js.map +1 -0
- package/lib/Fly/MachinePool.d.ts +39 -0
- package/lib/Fly/MachinePool.d.ts.map +1 -0
- package/lib/Fly/MachinePool.js +51 -0
- package/lib/Fly/MachinePool.js.map +1 -0
- package/lib/Fly/index.d.ts +7 -0
- package/lib/Fly/index.d.ts.map +1 -0
- package/lib/Fly/index.js +7 -0
- package/lib/Fly/index.js.map +1 -0
- package/lib/GCP/ComputeEnginePool.d.ts +41 -0
- package/lib/GCP/ComputeEnginePool.d.ts.map +1 -0
- package/lib/GCP/ComputeEnginePool.js +172 -0
- package/lib/GCP/ComputeEnginePool.js.map +1 -0
- package/lib/GCP/Database.d.ts +48 -0
- package/lib/GCP/Database.d.ts.map +1 -0
- package/lib/GCP/Database.js +115 -0
- package/lib/GCP/Database.js.map +1 -0
- package/lib/GCP/index.d.ts +7 -0
- package/lib/GCP/index.d.ts.map +1 -0
- package/lib/GCP/index.js +7 -0
- package/lib/GCP/index.js.map +1 -0
- package/lib/Hetzner/Database.d.ts +48 -0
- package/lib/Hetzner/Database.d.ts.map +1 -0
- package/lib/Hetzner/Database.js +91 -0
- package/lib/Hetzner/Database.js.map +1 -0
- package/lib/Hetzner/ServerPool.d.ts +35 -0
- package/lib/Hetzner/ServerPool.d.ts.map +1 -0
- package/lib/Hetzner/ServerPool.js +98 -0
- package/lib/Hetzner/ServerPool.js.map +1 -0
- package/lib/Hetzner/index.d.ts +7 -0
- package/lib/Hetzner/index.d.ts.map +1 -0
- package/lib/Hetzner/index.js +7 -0
- package/lib/Hetzner/index.js.map +1 -0
- package/lib/Host.d.ts +60 -0
- package/lib/Host.d.ts.map +1 -0
- package/lib/Host.js +31 -0
- package/lib/Host.js.map +1 -0
- package/lib/Kubernetes/Database.d.ts +40 -0
- package/lib/Kubernetes/Database.d.ts.map +1 -0
- package/lib/Kubernetes/Database.js +56 -0
- package/lib/Kubernetes/Database.js.map +1 -0
- package/lib/Kubernetes/DeploymentPool.d.ts +54 -0
- package/lib/Kubernetes/DeploymentPool.d.ts.map +1 -0
- package/lib/Kubernetes/DeploymentPool.js +49 -0
- package/lib/Kubernetes/DeploymentPool.js.map +1 -0
- package/lib/Kubernetes/index.d.ts +7 -0
- package/lib/Kubernetes/index.d.ts.map +1 -0
- package/lib/Kubernetes/index.js +7 -0
- package/lib/Kubernetes/index.js.map +1 -0
- package/lib/Pool.d.ts +66 -0
- package/lib/Pool.d.ts.map +1 -0
- package/lib/Pool.js +47 -0
- package/lib/Pool.js.map +1 -0
- package/lib/Providers.d.ts +19 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +31 -0
- package/lib/Providers.js.map +1 -0
- package/lib/ShardGroups.d.ts +24 -0
- package/lib/ShardGroups.d.ts.map +1 -0
- package/lib/ShardGroups.js +19 -0
- package/lib/ShardGroups.js.map +1 -0
- package/lib/Singleton.d.ts +110 -0
- package/lib/Singleton.d.ts.map +1 -0
- package/lib/Singleton.js +60 -0
- package/lib/Singleton.js.map +1 -0
- package/lib/Workflow.d.ts +251 -0
- package/lib/Workflow.d.ts.map +1 -0
- package/lib/Workflow.js +288 -0
- package/lib/Workflow.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/Bootstrap.d.ts +28 -0
- package/lib/internal/Bootstrap.d.ts.map +1 -0
- package/lib/internal/Bootstrap.js +257 -0
- package/lib/internal/Bootstrap.js.map +1 -0
- package/lib/internal/EntityRuntime.d.ts +40 -0
- package/lib/internal/EntityRuntime.d.ts.map +1 -0
- package/lib/internal/EntityRuntime.js +698 -0
- package/lib/internal/EntityRuntime.js.map +1 -0
- package/lib/internal/Gateway.d.ts +82 -0
- package/lib/internal/Gateway.d.ts.map +1 -0
- package/lib/internal/Gateway.js +218 -0
- package/lib/internal/Gateway.js.map +1 -0
- package/lib/internal/HostedPlatform.d.ts +36 -0
- package/lib/internal/HostedPlatform.d.ts.map +1 -0
- package/lib/internal/HostedPlatform.js +36 -0
- package/lib/internal/HostedPlatform.js.map +1 -0
- package/lib/internal/HostedRuntime.d.ts +58 -0
- package/lib/internal/HostedRuntime.d.ts.map +1 -0
- package/lib/internal/HostedRuntime.js +72 -0
- package/lib/internal/HostedRuntime.js.map +1 -0
- package/lib/internal/Naming.d.ts +12 -0
- package/lib/internal/Naming.d.ts.map +1 -0
- package/lib/internal/Naming.js +40 -0
- package/lib/internal/Naming.js.map +1 -0
- package/lib/internal/ObjectSharding.d.ts +141 -0
- package/lib/internal/ObjectSharding.d.ts.map +1 -0
- package/lib/internal/ObjectSharding.js +337 -0
- package/lib/internal/ObjectSharding.js.map +1 -0
- package/lib/internal/PoolHost.d.ts +80 -0
- package/lib/internal/PoolHost.d.ts.map +1 -0
- package/lib/internal/PoolHost.js +203 -0
- package/lib/internal/PoolHost.js.map +1 -0
- package/lib/internal/PoolHostService.d.ts +25 -0
- package/lib/internal/PoolHostService.d.ts.map +1 -0
- package/lib/internal/PoolHostService.js +10 -0
- package/lib/internal/PoolHostService.js.map +1 -0
- package/lib/internal/Wire.d.ts +60 -0
- package/lib/internal/Wire.d.ts.map +1 -0
- package/lib/internal/Wire.js +36 -0
- package/lib/internal/Wire.js.map +1 -0
- package/lib/internal/WorkflowGateway.d.ts +36 -0
- package/lib/internal/WorkflowGateway.d.ts.map +1 -0
- package/lib/internal/WorkflowGateway.js +124 -0
- package/lib/internal/WorkflowGateway.js.map +1 -0
- package/lib/internal/external-runner.d.ts +2 -0
- package/lib/internal/external-runner.d.ts.map +1 -0
- package/lib/internal/external-runner.js +7 -0
- package/lib/internal/external-runner.js.map +1 -0
- package/lib/internal/runner.d.ts +2 -0
- package/lib/internal/runner.d.ts.map +1 -0
- package/lib/internal/runner.js +5 -0
- package/lib/internal/runner.js.map +1 -0
- package/package.json +143 -3
- package/src/AWS/Database.ts +139 -0
- package/src/AWS/EcsPool.ts +118 -0
- package/src/AWS/index.ts +6 -0
- package/src/AWS/internal/Gateway.ts +82 -0
- package/src/Cloudflare/DurableObjectPool.ts +198 -0
- package/src/Cloudflare/PoolWorker.ts +124 -0
- package/src/Cloudflare/index.ts +6 -0
- package/src/Cloudflare/internal/Objects.ts +160 -0
- package/src/Cron.ts +202 -0
- package/src/Database.ts +116 -0
- package/src/Docker/Database.ts +94 -0
- package/src/Docker/SwarmPool.ts +83 -0
- package/src/Docker/index.ts +6 -0
- package/src/Entity.ts +621 -0
- package/src/Fly/Database.ts +102 -0
- package/src/Fly/MachinePool.ts +72 -0
- package/src/Fly/index.ts +6 -0
- package/src/GCP/ComputeEnginePool.ts +203 -0
- package/src/GCP/Database.ts +168 -0
- package/src/GCP/index.ts +6 -0
- package/src/Hetzner/Database.ts +142 -0
- package/src/Hetzner/ServerPool.ts +116 -0
- package/src/Hetzner/index.ts +6 -0
- package/src/Host.ts +68 -0
- package/src/Kubernetes/Database.ts +89 -0
- package/src/Kubernetes/DeploymentPool.ts +77 -0
- package/src/Kubernetes/index.ts +6 -0
- package/src/Pool.ts +104 -0
- package/src/Providers.ts +49 -0
- package/src/ShardGroups.ts +41 -0
- package/src/Singleton.ts +153 -0
- package/src/Workflow.ts +556 -0
- package/src/index.ts +11 -0
- package/src/internal/Bootstrap.ts +368 -0
- package/src/internal/EntityRuntime.ts +996 -0
- package/src/internal/Gateway.ts +366 -0
- package/src/internal/HostedPlatform.ts +83 -0
- package/src/internal/HostedRuntime.ts +118 -0
- package/src/internal/Naming.ts +44 -0
- package/src/internal/ObjectSharding.ts +578 -0
- package/src/internal/PoolHost.ts +330 -0
- package/src/internal/PoolHostService.ts +25 -0
- package/src/internal/Wire.ts +83 -0
- package/src/internal/WorkflowGateway.ts +188 -0
- package/src/internal/external-runner.ts +10 -0
- package/src/internal/runner.ts +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @alchemy.run/effect-cluster
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Effect Cluster](https://effect.website) for [Alchemy](https://alchemy.run). Effect Cluster runs stateful, addressable programs across a group of processes. An entity has one instance per id, like a chat room or a cart, and handles its messages one at a time. Instances are spread over runners by shard, and a Postgres database records which runner owns each shard and keeps the messages that must survive a restart. Deploy the database and a pool of runners on Docker, AWS, GCP, Kubernetes, Fly or Hetzner, or run each instance as a Durable Object on Cloudflare.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install alchemy @alchemy.run/effect-cluster @alchemy.run/docker effect
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A pool of runners, and the database they coordinate through:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// src/Cluster.ts
|
|
13
|
+
import * as ClusterDocker from "@alchemy.run/effect-cluster/Docker";
|
|
14
|
+
import * as Layer from "effect/Layer";
|
|
15
|
+
|
|
16
|
+
export const Database = ClusterDocker.Database("Cluster");
|
|
17
|
+
|
|
18
|
+
export const Default = ClusterDocker.SwarmPool("Default").pipe(Layer.provide(Database));
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
An entity, declared with its messages and its implementation, on that pool:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// src/Room.ts
|
|
25
|
+
import * as Cluster from "@alchemy.run/effect-cluster";
|
|
26
|
+
import { Entity } from "effect/cluster";
|
|
27
|
+
import * as Effect from "effect/Effect";
|
|
28
|
+
import * as Ref from "effect/Ref";
|
|
29
|
+
import { Rpc } from "effect/rpc";
|
|
30
|
+
import * as Schema from "effect/Schema";
|
|
31
|
+
import { Default } from "./Cluster.ts";
|
|
32
|
+
|
|
33
|
+
const Rooms = Entity.make("Room", [
|
|
34
|
+
Rpc.make("Join", { payload: { name: Schema.String }, success: Schema.Int }),
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export default class Room extends Cluster.Entity<Room>()(
|
|
38
|
+
Rooms,
|
|
39
|
+
{ main: import.meta.url },
|
|
40
|
+
Effect.gen(function* () {
|
|
41
|
+
return Effect.gen(function* () {
|
|
42
|
+
const members = yield* Ref.make(new Set<string>());
|
|
43
|
+
return Rooms.of({
|
|
44
|
+
Join: ({ payload }) =>
|
|
45
|
+
Ref.modify(members, (all) => {
|
|
46
|
+
const next = new Set(all).add(payload.name);
|
|
47
|
+
return [next.size, next];
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}).pipe(Effect.provide(Default)),
|
|
52
|
+
) {}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Any runtime calls a room by its id:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// src/Api.ts
|
|
59
|
+
import * as Docker from "@alchemy.run/docker";
|
|
60
|
+
import * as Effect from "effect/Effect";
|
|
61
|
+
import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
62
|
+
import Room from "./Room.ts";
|
|
63
|
+
|
|
64
|
+
export default class Api extends Docker.Service<Api>()(
|
|
65
|
+
"Api",
|
|
66
|
+
{ main: import.meta.url, port: 3000 },
|
|
67
|
+
Effect.gen(function* () {
|
|
68
|
+
const rooms = yield* Room;
|
|
69
|
+
return {
|
|
70
|
+
fetch: Effect.gen(function* () {
|
|
71
|
+
const lobby = yield* rooms.getByName("lobby");
|
|
72
|
+
const members = yield* lobby.Join({ name: "sam" });
|
|
73
|
+
return yield* HttpServerResponse.json({ members });
|
|
74
|
+
}).pipe(Effect.orDie),
|
|
75
|
+
};
|
|
76
|
+
}),
|
|
77
|
+
) {}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
And the Stack deploys the Api, which brings the room, the pool and the database with it:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// alchemy.run.ts
|
|
84
|
+
import * as Cluster from "@alchemy.run/effect-cluster";
|
|
85
|
+
import * as Docker from "@alchemy.run/docker";
|
|
86
|
+
import * as Alchemy from "alchemy";
|
|
87
|
+
import * as Effect from "effect/Effect";
|
|
88
|
+
import * as Layer from "effect/Layer";
|
|
89
|
+
import Api from "./src/Api.ts";
|
|
90
|
+
|
|
91
|
+
export default Alchemy.Stack(
|
|
92
|
+
"Rooms",
|
|
93
|
+
{
|
|
94
|
+
providers: Layer.mergeAll(Docker.providers(), Cluster.providers()),
|
|
95
|
+
state: Alchemy.localState(),
|
|
96
|
+
},
|
|
97
|
+
Effect.gen(function* () {
|
|
98
|
+
const api = yield* Api;
|
|
99
|
+
return { api: api.name };
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Swap `ClusterDocker` for `ClusterAWS`, `ClusterFly` or another cloud, and the room doesn't change.
|
|
105
|
+
|
|
106
|
+
Docs: [alchemy.run/cluster](https://alchemy.run/cluster) · [Setup](https://alchemy.run/cluster/setup) · [Tutorial](https://alchemy.run/cluster/tutorial/part-1). Reference: [alchemy.run/providers](https://alchemy.run/providers).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { Database as ClusterDatabase } from "../Database.ts";
|
|
3
|
+
import type { Providers } from "../Providers.ts";
|
|
4
|
+
export interface DatabaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* RDS instance class.
|
|
7
|
+
* @default "db.t4g.micro"
|
|
8
|
+
*/
|
|
9
|
+
instanceClass?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Postgres major version.
|
|
12
|
+
* @default "17"
|
|
13
|
+
*/
|
|
14
|
+
engineVersion?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Storage, in GiB.
|
|
17
|
+
* @default 20
|
|
18
|
+
*/
|
|
19
|
+
allocatedStorage?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Run a standby in a second Availability Zone.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
multiAZ?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* IPv4 CIDR block of the cluster's VPC.
|
|
27
|
+
* @default "10.44.0.0/16"
|
|
28
|
+
*/
|
|
29
|
+
cidrBlock?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The database an Effect Cluster coordinates through, on AWS, as a
|
|
33
|
+
* `Cluster.Database` Layer: Postgres on RDS, in a VPC of its own that the
|
|
34
|
+
* runners join. Every runner joins one security group, which reaches the
|
|
35
|
+
* database and the other runners on the runner port; nothing else does.
|
|
36
|
+
*
|
|
37
|
+
* ### Running the database on RDS
|
|
38
|
+
* **Example:** Postgres for the cluster
|
|
39
|
+
* ```typescript
|
|
40
|
+
* export const Database = ClusterAWS.Database("Cluster");
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* **Example:** A larger instance with a standby
|
|
44
|
+
* ```typescript
|
|
45
|
+
* export const Database = ClusterAWS.Database("Cluster", {
|
|
46
|
+
* instanceClass: "db.m7g.large",
|
|
47
|
+
* multiAZ: true,
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @primitive
|
|
52
|
+
*/
|
|
53
|
+
export declare const Database: (id: string, props?: DatabaseProps) => Layer.Layer<ClusterDatabase, never, import("@distilled.cloud/s3/Credentials").Credentials | import("effect/http/HttpClient").HttpClient | Providers | import("@alchemy.run/aws/Providers").Providers | import("@distilled.cloud/aws/Region").Region>;
|
|
54
|
+
//# sourceMappingURL=Database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sources":["../../src/AWS/Database.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAsB,QAAQ,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,QAAQ,OAAQ,MAAM,UAAS,aAAa,yPA6EtD,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as EC2 from "@alchemy.run/aws/EC2";
|
|
2
|
+
import * as RDS from "@alchemy.run/aws/RDS";
|
|
3
|
+
import * as Output from "alchemy/Output";
|
|
4
|
+
import { Random } from "alchemy/Random";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Redacted from "effect/Redacted";
|
|
8
|
+
import { clusterShardGroups, Database as ClusterDatabase } from "../Database.js";
|
|
9
|
+
import { RUNNER_PORT } from "../internal/Gateway.js";
|
|
10
|
+
/**
|
|
11
|
+
* The database an Effect Cluster coordinates through, on AWS, as a
|
|
12
|
+
* `Cluster.Database` Layer: Postgres on RDS, in a VPC of its own that the
|
|
13
|
+
* runners join. Every runner joins one security group, which reaches the
|
|
14
|
+
* database and the other runners on the runner port; nothing else does.
|
|
15
|
+
*
|
|
16
|
+
* ### Running the database on RDS
|
|
17
|
+
* **Example:** Postgres for the cluster
|
|
18
|
+
* ```typescript
|
|
19
|
+
* export const Database = ClusterAWS.Database("Cluster");
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* **Example:** A larger instance with a standby
|
|
23
|
+
* ```typescript
|
|
24
|
+
* export const Database = ClusterAWS.Database("Cluster", {
|
|
25
|
+
* instanceClass: "db.m7g.large",
|
|
26
|
+
* multiAZ: true,
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @primitive
|
|
31
|
+
*/
|
|
32
|
+
export const Database = (id, props = {}) => Layer.effect(ClusterDatabase, Effect.gen(function* () {
|
|
33
|
+
if (globalThis.__ALCHEMY_RUNTIME__) {
|
|
34
|
+
// Runners read their database from their own environment at runtime.
|
|
35
|
+
return { url: Redacted.make(""), shardGroups: undefined };
|
|
36
|
+
}
|
|
37
|
+
const network = yield* EC2.Network(`${id}Network`, {
|
|
38
|
+
cidrBlock: props.cidrBlock ?? "10.44.0.0/16",
|
|
39
|
+
availabilityZones: 2,
|
|
40
|
+
});
|
|
41
|
+
const runners = yield* EC2.SecurityGroup(`${id}RunnersGroup`, {
|
|
42
|
+
vpcId: network.vpcId,
|
|
43
|
+
description: "Effect Cluster runners",
|
|
44
|
+
egress: [{ ipProtocol: "-1", cidrIpv4: "0.0.0.0/0" }],
|
|
45
|
+
});
|
|
46
|
+
// Runners send each other messages for the shards they own.
|
|
47
|
+
yield* EC2.SecurityGroupRule(`${id}RunnerPeers`, {
|
|
48
|
+
groupId: runners.groupId,
|
|
49
|
+
type: "ingress",
|
|
50
|
+
ipProtocol: "tcp",
|
|
51
|
+
fromPort: RUNNER_PORT,
|
|
52
|
+
toPort: RUNNER_PORT,
|
|
53
|
+
referencedGroupId: runners.groupId,
|
|
54
|
+
});
|
|
55
|
+
const databaseGroup = yield* EC2.SecurityGroup(`${id}DatabaseGroup`, {
|
|
56
|
+
vpcId: network.vpcId,
|
|
57
|
+
description: "Effect Cluster database",
|
|
58
|
+
ingress: [
|
|
59
|
+
{ ipProtocol: "tcp", fromPort: 5432, toPort: 5432, referencedGroupId: runners.groupId },
|
|
60
|
+
],
|
|
61
|
+
egress: [{ ipProtocol: "-1", cidrIpv4: "0.0.0.0/0" }],
|
|
62
|
+
});
|
|
63
|
+
const subnets = yield* RDS.DBSubnetGroup(`${id}Subnets`, {
|
|
64
|
+
description: "Effect Cluster database",
|
|
65
|
+
subnetIds: network.publicSubnetIds,
|
|
66
|
+
});
|
|
67
|
+
const password = yield* Random(`${id}Password`, { bytes: 24 });
|
|
68
|
+
const instance = yield* RDS.DBInstance(`${id}Postgres`, {
|
|
69
|
+
engine: "postgres",
|
|
70
|
+
engineVersion: props.engineVersion ?? "17",
|
|
71
|
+
dbInstanceClass: props.instanceClass ?? "db.t4g.micro",
|
|
72
|
+
allocatedStorage: props.allocatedStorage ?? 20,
|
|
73
|
+
dbName: "effect_cluster",
|
|
74
|
+
masterUsername: "effect",
|
|
75
|
+
masterUserPassword: password.text,
|
|
76
|
+
multiAZ: props.multiAZ ?? false,
|
|
77
|
+
dbSubnetGroupName: subnets.dbSubnetGroupName,
|
|
78
|
+
vpcSecurityGroupIds: [databaseGroup.groupId],
|
|
79
|
+
publiclyAccessible: false,
|
|
80
|
+
storageEncrypted: true,
|
|
81
|
+
skipFinalSnapshot: true,
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
// RDS requires TLS. Runners verify the certificate against the RDS
|
|
85
|
+
// certificate authority their image trusts (`ClusterAWS.EcsPool`).
|
|
86
|
+
url: Output.all(instance.endpointAddress, instance.endpointPort, password.text).pipe(Output.map(([host, port, text]) => Redacted.make(`postgres://effect:${encodeURIComponent(text.pipe(Redacted.value))}@${host}:${port ?? 5432}/effect_cluster?sslmode=require`))),
|
|
87
|
+
network: {
|
|
88
|
+
kind: "aws",
|
|
89
|
+
vpcId: network.vpcId,
|
|
90
|
+
subnetIds: network.publicSubnetIds,
|
|
91
|
+
securityGroupId: runners.groupId,
|
|
92
|
+
},
|
|
93
|
+
shardGroups: yield* clusterShardGroups(id),
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
//# sourceMappingURL=Database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Database.js","sources":["../../src/AWS/Database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA+BrD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,QAAQ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AI,CAAC,CAAC,IAAI,CAClF,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAChC,QAAQ,CAAC,IAAI,CACX,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,iCAAiC,CAC5H,CACF,CACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,KAAc;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,SAAS,EAAE,OAAO,CAAC,eAAe;YAClC,eAAe,EAAE,OAAO,CAAC,OAAO;SACjC;QACD,WAAW,EAAE,KAAK,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type PoolSettings } from "../internal/PoolHost.ts";
|
|
2
|
+
export interface EcsPoolOptions extends PoolSettings {
|
|
3
|
+
/**
|
|
4
|
+
* Number of runners.
|
|
5
|
+
* @default 2
|
|
6
|
+
*/
|
|
7
|
+
replicas?: number;
|
|
8
|
+
/**
|
|
9
|
+
* CPU units of each runner (1024 = 1 vCPU).
|
|
10
|
+
* @default 512
|
|
11
|
+
*/
|
|
12
|
+
cpu?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Memory of each runner, in MiB.
|
|
15
|
+
* @default 1024
|
|
16
|
+
*/
|
|
17
|
+
memory?: number;
|
|
18
|
+
/**
|
|
19
|
+
* CPU architecture of the pool. The image is built for it on the
|
|
20
|
+
* deploying machine.
|
|
21
|
+
* @default "X86_64"
|
|
22
|
+
*/
|
|
23
|
+
architecture?: "X86_64" | "ARM64";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run a pool of Effect Cluster runners on ECS Fargate: an ECS service whose tasks
|
|
27
|
+
* host every class given this pool, in the database's VPC, behind a
|
|
28
|
+
* load balancer that serves their gateway to callers anywhere. Requires a
|
|
29
|
+
* database in an AWS VPC — `ClusterAWS.Database`.
|
|
30
|
+
*
|
|
31
|
+
* Runners reach each other and the database through the cluster's runner
|
|
32
|
+
* security group; the load balancer only reaches the gateway, which checks
|
|
33
|
+
* every call's token.
|
|
34
|
+
*
|
|
35
|
+
* ### Running on ECS
|
|
36
|
+
* **Example:** Two runners on Fargate
|
|
37
|
+
* ```typescript
|
|
38
|
+
* export const Database = ClusterAWS.Database("Cluster");
|
|
39
|
+
* export const Default = ClusterAWS.EcsPool("Default", { replicas: 2 }).pipe(
|
|
40
|
+
* Layer.provide(Database),
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* **Example:** Larger Graviton runners
|
|
45
|
+
* ```typescript
|
|
46
|
+
* export const Default = ClusterAWS.EcsPool("Default", {
|
|
47
|
+
* cpu: 2048,
|
|
48
|
+
* memory: 4096,
|
|
49
|
+
* architecture: "ARM64",
|
|
50
|
+
* }).pipe(Layer.provide(Database));
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @primitive
|
|
54
|
+
*/
|
|
55
|
+
export declare const EcsPool: (id: string, options?: EcsPoolOptions) => import("effect/Layer").Layer<import("../internal/PoolHostService.ts").PoolHost, never, import("../Database.ts").Database | import("../Providers.ts").Providers | import("@alchemy.run/aws/Providers").Providers | import("alchemy").Stack>;
|
|
56
|
+
//# sourceMappingURL=EcsPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EcsPool.d.ts","sources":["../../src/AWS/EcsPool.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAa9F,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,OAAO,OAAQ,MAAM,YAAW,cAAc,+OA8CvD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as ECS from "@alchemy.run/aws/ECS";
|
|
2
|
+
import * as Output from "alchemy/Output";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { GATEWAY_PORT, RUNNER_PORT } from "../internal/Gateway.js";
|
|
5
|
+
import { makePoolLayer, RUNNER_DOCKERFILE } from "../internal/PoolHost.js";
|
|
6
|
+
/** Where AWS publishes the certificate authorities of every RDS region. */
|
|
7
|
+
const RDS_CA_BUNDLE = "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem";
|
|
8
|
+
const RDS_RUNNER_DOCKERFILE = RUNNER_DOCKERFILE.replace("ENV NODE_ENV=production", `ENV NODE_ENV=production
|
|
9
|
+
ADD ${RDS_CA_BUNDLE} /etc/ssl/rds-ca.pem
|
|
10
|
+
ENV NODE_EXTRA_CA_CERTS=/etc/ssl/rds-ca.pem`);
|
|
11
|
+
import { awsNetworkOf, makeAwsGateway } from "./internal/Gateway.js";
|
|
12
|
+
/**
|
|
13
|
+
* Run a pool of Effect Cluster runners on ECS Fargate: an ECS service whose tasks
|
|
14
|
+
* host every class given this pool, in the database's VPC, behind a
|
|
15
|
+
* load balancer that serves their gateway to callers anywhere. Requires a
|
|
16
|
+
* database in an AWS VPC — `ClusterAWS.Database`.
|
|
17
|
+
*
|
|
18
|
+
* Runners reach each other and the database through the cluster's runner
|
|
19
|
+
* security group; the load balancer only reaches the gateway, which checks
|
|
20
|
+
* every call's token.
|
|
21
|
+
*
|
|
22
|
+
* ### Running on ECS
|
|
23
|
+
* **Example:** Two runners on Fargate
|
|
24
|
+
* ```typescript
|
|
25
|
+
* export const Database = ClusterAWS.Database("Cluster");
|
|
26
|
+
* export const Default = ClusterAWS.EcsPool("Default", { replicas: 2 }).pipe(
|
|
27
|
+
* Layer.provide(Database),
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* **Example:** Larger Graviton runners
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export const Default = ClusterAWS.EcsPool("Default", {
|
|
34
|
+
* cpu: 2048,
|
|
35
|
+
* memory: 4096,
|
|
36
|
+
* architecture: "ARM64",
|
|
37
|
+
* }).pipe(Layer.provide(Database));
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @primitive
|
|
41
|
+
*/
|
|
42
|
+
export const EcsPool = (id, options = {}) => makePoolLayer({
|
|
43
|
+
label: "ClusterAWS.EcsPool",
|
|
44
|
+
id,
|
|
45
|
+
settings: options,
|
|
46
|
+
expected: "an AWS VPC (ClusterAWS.Database)",
|
|
47
|
+
// The runner image trusts the RDS certificate authority, so runners
|
|
48
|
+
// verify the database's certificate.
|
|
49
|
+
dockerfile: RDS_RUNNER_DOCKERFILE,
|
|
50
|
+
network: awsNetworkOf,
|
|
51
|
+
gateway: (_name, network) => makeAwsGateway(id, network, "ip"),
|
|
52
|
+
nodes: ({ network, gateway, program, environment }) => Effect.gen(function* () {
|
|
53
|
+
const cluster = yield* ECS.Cluster(`${id}Cluster`, {});
|
|
54
|
+
yield* ECS.Service(`${id}Pool`, {
|
|
55
|
+
cluster,
|
|
56
|
+
context: program.pipe(Output.map((p) => p.dir)),
|
|
57
|
+
// Other runners reach the runner port; the load balancer, the gateway.
|
|
58
|
+
container: {
|
|
59
|
+
name: "runner",
|
|
60
|
+
portMappings: [
|
|
61
|
+
{ containerPort: RUNNER_PORT, hostPort: RUNNER_PORT, protocol: "tcp" },
|
|
62
|
+
{ containerPort: GATEWAY_PORT, hostPort: GATEWAY_PORT, protocol: "tcp" },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
desiredCount: options.replicas ?? 2,
|
|
66
|
+
cpu: options.cpu ?? 512,
|
|
67
|
+
memory: options.memory ?? 1024,
|
|
68
|
+
runtimePlatform: {
|
|
69
|
+
cpuArchitecture: options.architecture ?? "X86_64",
|
|
70
|
+
operatingSystemFamily: "LINUX",
|
|
71
|
+
},
|
|
72
|
+
vpcId: network.vpcId,
|
|
73
|
+
subnets: [...network.subnetIds],
|
|
74
|
+
securityGroups: [network.securityGroupId, gateway.securityGroupId],
|
|
75
|
+
assignPublicIp: true,
|
|
76
|
+
loadBalancers: [
|
|
77
|
+
{
|
|
78
|
+
targetGroupArn: gateway.targetGroupArn,
|
|
79
|
+
containerName: "runner",
|
|
80
|
+
containerPort: GATEWAY_PORT,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
env: environment,
|
|
84
|
+
});
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=EcsPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EcsPool.js","sources":["../../src/AWS/EcsPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAE9F,2EAA2E;AAC3E,MAAM,aAAa,GAAG,mEAAmE,CAAC;AAE1F,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,OAAO,CACrD,yBAAyB,EACzB;MACI,aAAa;4CACyB,CAC3C,CAAC;AACF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA0BrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM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AAe,EAAE;gBACf,eAAe,EAAE,OAAO,CAAC,YAAY,IAAI,QAAQ;gBACjD,qBAAqB,EAAE,OAAO;aAC/B;YACD,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;YAC/B,cAAc,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC;YAClE,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE;gBACb;oBACE,cAAc,EAAE,OAAO,CAAC,cAAmC;oBAC3D,aAAa,EAAE,QAAQ;oBACvB,aAAa,EAAE,YAAY;iBAC5B;aACF;YACD,GAAG,EAAE,WAAgD;SACtD,CAAC,CAAC;IACL,CAAC,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../src/AWS/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/lib/AWS/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/AWS/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|