Native FastCGI codec, streaming Responder/Authorizer/Filter and TCP/POSIX server
git clone https://github.com/Ryan-1125/moonfcgi.git
cd moonfcgi
moon update
moon check --target native
moon build --target native
moon test --target native
moon run cmd/stream --target native -- 127.0.0.1:9000| 分发入口 | 版本 | 接口范围 |
|---|---|---|
| 本仓库 / 本地打包归档 | 0.2.0 | 缓冲与流式 API、三个角色、POSIX 部署、生命周期及诊断 |
| Mooncakes | 0.1.0 | 增量协议核心、缓冲式 TCP Responder |
async fn main {
let handler : @server.StreamHandler = (request, response) => {
response.start(headers=[("Content-Type", "application/octet-stream")])
while request.body.read() is Some(chunk) {
response.write(chunk)
}
}
@server.serve_stream("127.0.0.1:9000", handler)
}nginx -p <仓库绝对路径>/ -c examples/nginx-stream.conf
curl --data-binary @payload.bin http://127.0.0.1:8080/echo -o echoed.bin
curl http://127.0.0.1:8080/download -o download.bin| 入口 | 内容 |
|---|---|
| 架构与目录 | 模块职责、数据路径与源码位置 |
| API 与协议契约 | 公开接口、角色、字节语义与资源约束 |
| 流式处理 | STDIN/DATA、输出背压与错误完成语义 |
| 服务生命周期 | Control、事件、统计、队列与期限配置 |
| 安装与部署 | 源码工作区、Nginx、TCP/Unix/fd 接入 |
| 测试与兼容性 | 真实联调结果、版本和复现命令 |
| 参考来源 | 规范、成熟实现及参考范围 |
| 项目申报书 | 项目定位、场景与验收交付 |
pub struct Decoder {
// private fields
}pub struct Limits {
body_bytes : Int
params_bytes : Int
param_count : Int
response_bytes : Int
connections : Int
}fn Limits::new(body_bytes? : Int, params_bytes? : Int, param_count? : Int, response_bytes? : Int, connections? : Int) -> Limits raise ProtocolErrorpub struct ParamsDecoder {
// private fields
}pub struct Request {
id : Int
token : Int64
params : Array[(Bytes, Bytes)]
body : Bytes
// private fields
}fn Response::new(body : Bytes, status? : Int, headers? : Array[(String, String)], stderr? : Bytes) -> Response raise ProtocolErrorpub struct Session {
// private fields
}pub(all) enum StreamEvent {
Send(Array[Record])
Start(RequestHead)
Input(Int64, Int, Bytes)
InputEnd(Int64, Int)
Aborted(Int64)
Close
}pub struct StreamSession {
// private fields
}fn StreamSession::accept(self : StreamSession, record : Record) -> Array[StreamEvent] raise ProtocolErrorfn StreamSession::complete(self : StreamSession, head : RequestHead, app_status? : UInt) -> Array[StreamEvent]Install
Download zipNative FastCGI codec, streaming Responder/Authorizer/Filter and TCP/POSIX server