feat(edge-workers): Cloudflare Workers-style serverless edge runtime#4
Open
minjcore wants to merge 1 commit into
Open
feat(edge-workers): Cloudflare Workers-style serverless edge runtime#4minjcore wants to merge 1 commit into
minjcore wants to merge 1 commit into
Conversation
Add apps/edge-workers, a serverless edge runtime built on the Fluxor verticle model. Flow: HTTP/IO -> CPU (event loop + worker pool verticle) -> lightweight engine (PHP/Node subprocess) -> user script. - engine.go: Engine interface + PHP/Node subprocess engines (timeout, stdin/stdout JSON contract). JVM intentionally excluded as too heavy. - verticle.go: EdgeVerticle dispatches on its event loop (route match, <20us) and offloads the blocking subprocess to the worker pool. - worker.go: worker model, route registry (longest-prefix), request/ response contract. Scripts handle logic only -- no HTTP/network. - kv.go: in-memory KV store (namespaces + TTL) via snapshot/write-back. - cron.go: cron triggers via pkg/scheduler, safe expression validation. - server.go: HTTP gateway (data plane) + management API (control plane) with bearer-token auth (ADMIN_TOKEN, constant-time compare). - main.go: bootstrap via pkg/entrypoint, env-configurable ports, demo worker seeding. - workers/: demo scripts (hello.php, echo.js, counter.php KV, heartbeat.js cron). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tổng quan
apps/edge-workers— serverless edge runtime kiểu Cloudflare Workers, xây trên mô hình verticle của Fluxor.Execution flow:
Event loop chỉ dispatch (route match, race-free); worker pool chạy subprocess blocking → event loop không bao giờ nghẽn. Dùng runtime thật của Fluxor:
pkg/core(verticle + eventloop + worker pool),pkg/scheduler(cron),pkg/entrypoint(bootstrap).Features
php) + Node (node) chạy subprocess ngắn hạn (1 request = 1 "isolate"), timeout cứng, capture stdout/stderr. Java loại cố ý (quá nặng cho per-request edge).put/delete) → write-back sau khi response xong. State bền vững cross-request, không cần network.pkg/scheduler; fire bằng synthetic requesttrigger:"scheduled"qua cùng đường eventloop→pool. Validate an toàn (cron sai → 400, không crash).GET/POST/DELETE /workers+/health, deploy/xoá worker lúc runtime không cần restart. Bearer-token auth (ADMIN_TOKEN, so sánh constant-time);/healthđể mở.EDGE_ADDR/ADMIN_ADDR), cross-compile static linux binary (CGO off), 4 demo worker seed sẵn.Files
engine.go·worker.go·kv.go·verticle.go·cron.go·server.go·main.go·workers/{hello.php,echo.js,counter.php,heartbeat.js}·README.md·Makefile·config.jsonĐã test
gofmt+go build+go vetsạch.🤖 Generated with Claude Code