Files
chiyi 41df889a1a v2.0.0: error-channel APIs, correctness fixes, and server hardening
BREAKING CHANGES:
- Guard interface: Guard(ctx Ctx) error; returning error short-circuits
  (subsequent guards and the method no longer execute)
- Wired[T]() (*T, error); New() may return error; failed wiring is sticky
- BindService/BindGuard/BindRoute return error; routes accept guards
  (guards receive merged query/form params as Ctx.State)
- registration panics after Start; Ctx.Ip honors X-Forwarded-For/X-Real-IP
- internal errors sanitized to fixed client messages

FIXES:
- int64 precision loss: /cell data decoded from raw JSON bytes and
  responses serialized with json.Number (no float64 round-trip)
- enum values range-checked before uint8 conversion (256 no longer
  truncates to 0 and slips through)
- logger: files failing name parsing are no longer deleted; log channel
  never blocks request goroutines; ConfigLogger is race-free;
  logWriterWorker unlock bug fixed
- stream writer panics recovered (process no longer crashes);
  streamDone closed exactly once
- generated Go client emits definitions for pointer-to-enum/struct fields
- anonymous structs rejected at registration; isPrivate safe on empty names
- removed dead Result.Id and RequestInfo.Type

ADDITIONS:
- graceful shutdown (Shutdown), StartOn, server timeouts by default
  (Read 60s/Idle 120s/Write off), SetTimeouts/SetMaxConcurrency
- big-int-safe JSON in the generated TS client (>2^53 as BigInt)
- example/ demo services and cmd/genexample artifact generator
2026-09-03 15:32:07 +08:00

35 lines
829 B
Go

// genexample 重新生成 example/gen 下的客户端产物(Go + TS)。
// 在仓库根目录执行:go run ./cmd/genexample
package main
import (
"fmt"
"io/fs"
"os"
"path/filepath"
"github.com/cyi-cc/fun"
"github.com/cyi-cc/fun/example/demo"
)
func main() {
f := fun.New()
for _, svc := range []any{&demo.OrderSvc{}, &demo.ChatSvc{}} {
f.BindServiceForGen(svc) // 只登记元信息,不触发依赖装配
}
fun.SetOutput("./example/gen")
fun.GenCode(fun.GenGo{}, fun.GenTs{})
err := filepath.WalkDir("./example/gen", func(path string, d fs.DirEntry, err error) error {
if err == nil && !d.IsDir() {
rel, _ := filepath.Rel("./example/gen", path)
fmt.Println("生成:", filepath.ToSlash(rel))
}
return err
})
if err != nil {
fmt.Fprintln(os.Stderr, "walk output:", err)
os.Exit(1)
}
}