How fudengming/astrbot-t2irouter works
AstrBot T2I Router is a Go HTTP router that selects the first reachable configured text-to-image backend and keeps generated-image lookups pinned to that backend. The principal flow is generation request → backend selection → forwarding or redirect → ID binding → later data lookup and redirect. In-memory bindings expire by TTL and are also cleaned in batches. The source excerpt is partial, so some relationships below rely on the README’s explicit workflow description rather than inspected implementation details.
Main entry points: main.go Generate Handler
Components 13
Router Runtime
- Config and Server
main.go - HTTP Dispatch
main.go
Generation Routing
- Generate Handler
main.go - Backend Selection
main.go - TCP Connectivity Check
main.go - Request Forwarding
main.go - Response ID Parsing
main.go
ID Bindings
- Binding Table
main.go - Binding Cleanup
main.go - Data Handler
main.go - 307 Redirect
main.go
Backend Services
- Text-to-Image Backend
Other components
- Client
Connections 17
- Client → HTTP Dispatch: sends requests
README.md - Config and Server → HTTP Dispatch: serves requests
main.go - HTTP Dispatch → Generate Handler: routes generation
main.go - HTTP Dispatch → Data Handler: routes data lookup
main.go - Generate Handler → Backend Selection: selects backend
README.md - Backend Selection → TCP Connectivity Check: checks reachability
README.md - TCP Connectivity Check → Text-to-Image Backend: tests TCP connection
README.md - Generate Handler → Request Forwarding: forwards JSON request
README.md - Request Forwarding → Text-to-Image Backend: sends generation request
README.md - Generate Handler → 307 Redirect: redirects non-JSON request
README.md - Text-to-Image Backend → Response ID Parsing: returns response
README.md - Generate Handler → Response ID Parsing: parses response ID
main.go - Generate Handler → Binding Table: binds ID to backend
main.go - Binding Cleanup → Binding Table: deletes expired entries
main.go - Data Handler → Binding Table: looks up ID
main.go - Data Handler → 307 Redirect: redirects to bound backend
README.md - 307 Redirect → Client: returns 307
README.md