1.7 KiB
1.7 KiB
Quickstart: Modular Proxy & Cache Segmentation
1. Prepare Workspace
- Ensure Go 1.25+ toolchain is installed (
go version). - From repo root, run
go mod tidy(ormake depsif defined) to sync modules. - Export
ANY_HUB_CONFIGpointing to your working config (optional).
2. Create/Update Hub Module
- Copy
internal/hubmodule/template/tointernal/hubmodule/<module-key>/and rename the package/types. - In the new package's
init(), callhubmodule.MustRegister(hubmodule.ModuleMetadata{Key: "<module-key>", ...})to describe supported protocols、缓存策略与迁移阶段。 - Register runtime behavior (proxy handler) from your module by calling
proxy.RegisterModuleHandler("<module-key>", handler)during initialization. - Add tests under the module directory and run
make modules-test(delegates togo test ./internal/hubmodule/...).
3. Bind Module via Config
- Edit
config.tomland setModule = "<module-key>"inside the target[[Hub]]block (omit to uselegacy). - (Optional) Override cache behavior per hub using existing fields (
CacheTTL, etc.). - Run
ANY_HUB_CONFIG=./config.toml go test ./...to ensure loader validation passes.
4. Run and Verify
- Start the binary:
go run ./cmd/any-hub --config ./config.toml. - Send traffic to the hub's domain/port and watch logs for
module_key=<module-key>tags. - Inspect
./storage/<hub>/to confirm.bodyfiles are written by the module. - Exercise rollback by switching
Moduleback tolegacyif needed.
5. Ship
- Commit module code + config docs.
- Update release notes mentioning the module key, migration guidance, and related diagnostics.
- Monitor cache hit/miss metrics post-deploy; adjust TTL overrides if necessary.