GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing alchemy.run — Alchemy · the tightest feedback loop from edit to production The tightest feedback loop from edit to productionCloud programs composed from Layers: type-checked, emulated locally, tested live, and deployed per pull request. src/api.ts export default Cloudflare.WorkerCloudflare.Worker( "Api", { main: import.meta.url }, Effect.gen(function* () { const photos = yield* Photos; return { fetch: Effect.gen(function* () { const request = yield* HttpServerRequest; yield* photos.upload(request.url, yield* request.text); return HttpServerResponse.empty({ status: 201 }); }), }; }).pipe(Effect.provide(PhotosR2PhotosR2)), ); export default Cloudflare.WorkerCloudflare.Worker( "Api", { main: import.meta.url, }, Effect.gen(function* () { const photos = yield* Photos; return { fetch: handler }; }).pipe(Effect.provide(PhotosR2PhotosR2)), ); ~/my-appDEPLOY
Every step is optimizedIterate on your machine and then let CI deploy a preview, test it, and ship it on merge. The type checker answers in milliseconds, emulated tests in seconds, and the real cloud in about 20 seconds. See the example app and benchmark on GitHub→ Your machineCI/CD StagedThe agent's typing is staged. The type check itself answers in milliseconds. my-app — src/api.ts api.tsapi.test.ts 1export default Cloudflare.Worker( 2 "Api", 3 { main: import.meta.url }, 4 Effect.gen(function* () { 5 return { 6 fetch: Effect.gen(function* () { 7 const request = yield* HttpServerRequest; 8 return HttpServerResponse.empty({ status: 201 }); 9 }), 10 }; 11 }), 12); agent · my-appTYPE-CHECK › Your machine · edit Infrastructure is part of your applicationOther IaC tools split an app into two programs, but every feature you build crosses that line. In Alchemy, a Layer owns its infrastructure and service implementation so that features can be decomposed. PHOTOS MODULE runtime programinfrastructure program
src/Photos.ts export class Photos extends Context.Service<Photos, {
upload(name: string, body: string): Effect.Effect<void>;
}>()("Photos") {}
export const PhotosR2PhotosR2 = Layer.effect(
Photos,
Effect.gen(function* () {
const bucket = yield* Cloudflare.R2.BucketCloudflare.R2.Bucket("Photos");
const photos = yield* Cloudflare.R2.ReadWriteBucketCloudflare.R2.ReadWriteBucket(bucket);
return {
upload: (name, body) => photos.put(name, body)photos.put(name, body),
};
}),
);Your machine · type-check Type checking proves your infra is correctEach Layer declares what it needs in its type: the resources it creates, the access it grants, and the services it calls. Leave one out and the program doesn't compile, so a broken stack fails in your editor in milliseconds, before anything deploys. src/Photos.ts✗ 1 error export const PhotosS3 = Layer.effect( Photos, Effect.gen(function* () { const bucket = yield* AWS.S3.Bucket("Photos"); const write = yield* AWS.S3.GetObjectGetObject(bucket); return { upload: (name, body) => write({ Key: name, Body: body }), ✗ Object literal may only specify known properties, and 'Body' does not exist in type 'Omit<GetObjectRequest, "Bucket">'. }; }), ); iam-policy.yamlgenerated at deploy # the Api function's role Statement: - Effect: Allow Action: - s3:GetObjectGetObject Resource: - arn:aws:s3:::my-app-photos-x7k2/* Your machine · test, emulated Get fast feedback with local emulation
alchemy.run.ts import Api from "./src/api.ts"; export default Alchemy.Stack( "my-app", { providers: Cloudflare.providers() }, Effect.gen(function* () { // backend: a Cloudflare Worker, run locally in workerd const api = yield* Api; // frontend: a Vite app that calls it const web = yield* Cloudflare.Website.Vite("Web", { env: { VITE_API_URL: api.url }, }); return { web: web.url, api: api.url }; }), ); ~/my-appDEV Your machine · test, live Test a live deployment when ready to PROnce it works locally, run the same test without test/api.test.ts const { test, beforeAll, afterAll, deploy, destroy } = Test.make({ providers: Cloudflare.providers(), dev: !!process.env.LOCAL, // emulated, or the real cloud }); const stack = beforeAll(deploy(Stack)); // its own stage afterAll(destroy(Stack)); test("PUT + GET round-trips through R2", Effect.gen(function* () { const { url } = yield* stack; const res = yield* HttpClient.get(`${url}/object/hello.txt`); expect(yield* res.text).toBe("hi!"); })); CI · pr-1729TEST
CI/CD · preview per PR Deploy a preview stage in CI before mergingCI deploys each pull request to its own stage, runs the same tests, and comments a link to try it. The comment is a resource in the same program, so it is updated on every push and deleted with the preview. Merging deploys to production. alchemy.run.ts const api = yield* Api;const pr = yield* Config.option(Config.Int("PULL_REQUEST"));const sha = yield* Config.String("GITHUB_SHA"); if (Option.isSome(pr)) { yield* GitHub.Comment("Preview", { owner: "acme", repository: "my-app", issueNumber: pr.value, body: Output.interpolate`Preview: ${api.url} (${sha})`, allowDelete: true, });} github.com/acme/my-app/pull/147 Add image upload to /photos #147 Open feature/photo-upload→main
Production · monitoring Disciplined monitoring on Day 1Provide one Layer and every request is traced and logged with OpenTelemetry from the first deploy. Its datasets, dashboards and alert monitors are resources in the same program, so monitoring ships with the app. Swap the Layer to send telemetry to a different platform. src/Observability.ts export const Observability = Layer.unwrap( Effect.gen(function* () { const traces = yield* Axiom.Dataset("Traces", tracesProps); const logs = yield* Axiom.Dataset("Logs", logsProps); const token = yield* Axiom.ApiToken("Ingest", ingestProps); yield* Axiom.Dashboard("Dashboard", dashboardProps); yield* Axiom.Monitor("Errors", errorRateProps); return Axiom.Telemetry({ token, traces, logs }); }),); axiom · my-appALERTING errors / min27
Photos errorscount(error) > 10 ✗ monitor fired → sent to the agent: Photos.upload failing Loved by the people shipping with itWhat builders say after putting Alchemy in front of their agents, their Cloudflare apps, and their production infrastructure.
Get started.
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |