Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Bolt — inline in ioLoop. Maximum throughput, zero dispatch overhead. Bolt = Feather{Dispatch: Inline} // Arrow — goroutine pool dispatch. Arrow = Feather{Dispatch: Pool} // Spear — goroutine owns connection with blocking I/O. // Go runtime auto-creates OS threads, avoiding ioLoop starvation. Spear = Feather{Dispatch: Takeover} // Semantic presets — pick by route behavior: Plaintext = Bolt // static text, health checks JSON = Bolt // JSON encode, no I/O Query = Spear // DB/Redis short I/O Render = Spear // DB + template/HTML )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Workers int
RingSize uint32
ReadBufSize int
MaxHeaderCount int
MaxHeaderSize int
MaxConnsPerWorker int
HandlerPoolSize int // goroutine pool size per worker (Pool dispatch routes)
Feathers map[string]Feather // per-route feather config ("METHOD /path" → Feather)
DefaultFeather Feather // fallback feather for routes not in Feathers
ReadTimeout time.Duration // max time to receive a complete request (0 = disabled)
WriteTimeout time.Duration // max time to send a response (0 = disabled)
IdleTimeout time.Duration // max time a keep-alive conn can be idle (0 = disabled)
}
type DispatchMode ¶
type DispatchMode uint8
DispatchMode controls how the handler goroutine is scheduled.
const ( // Inline runs the handler directly in the ioLoop goroutine. // Zero overhead, but blocks the event loop during execution. // Use for handlers with no I/O wait (plaintext, JSON, cached). Inline DispatchMode = iota + 1 // Pool dispatches the handler to a bounded goroutine pool. // ~1μs overhead. Use for short I/O (DB query, Redis). Pool // Spawn creates a new goroutine per request. // ~2-3μs overhead. Use for heavy compute or variable latency. Spawn // Takeover spawns a goroutine that owns the connection. // The goroutine loops read→handle→write directly, bypassing ioLoop // until the connection goes idle (EAGAIN). Best for DB/Redis I/O // where handler latency dominates — eliminates doneCh/wake/re-arm // overhead between requests on the same connection. Takeover )
func (DispatchMode) String ¶
func (m DispatchMode) String() string
type Feather ¶
type Feather struct {
Dispatch DispatchMode
StaticResponse []byte // pre-built full HTTP response; bypasses handler entirely
}
Feather is the per-route tuning system for Wing. Only axes that are actually read by the transport are kept.
func (Feather) With ¶
func (f Feather) With(opts ...FeatherOption) Feather
With returns a copy of f with the given options applied.
type FeatherOption ¶
type FeatherOption func(*Feather)
FeatherOption modifies a Feather.
func Dispatch ¶
func Dispatch(m DispatchMode) FeatherOption
Dispatch returns a FeatherOption that sets the dispatch mode.
func Static ¶
func Static(resp []byte) FeatherOption
Static returns a FeatherOption that sets a pre-built static response.
type FeatherTable ¶
type FeatherTable struct {
// contains filtered or unexported fields
}
FeatherTable maps method+path to a Feather for per-route dispatch decisions. Lookup is two map reads (method → path → Feather), zero allocation.
Usage:
wing.New(wing.Config{
Feathers: map[string]Feather{
"GET /plaintext": wing.Bolt,
"GET /json": wing.Bolt,
"GET /db": wing.Arrow,
},
})
func NewFeatherTable ¶
func NewFeatherTable(routes map[string]Feather, def Feather) FeatherTable
NewFeatherTable builds a FeatherTable from a user-friendly string map. Keys are "METHOD /path" (e.g. "GET /plaintext"). Default feather is used for routes not in the table.
func (*FeatherTable) Lookup ¶
func (ft *FeatherTable) Lookup(method, path string) Feather
Lookup returns the Feather for the given method and path. Two map reads, zero allocation. Returns default if not found.
type RawRequest ¶
type RawRequest interface {
RawMethod() string
RawPath() []byte
RawHeader(name string) []byte
RawBody() []byte
Fd() int32
KeepAlive() bool
}
RawRequest provides low-level access to Wing's request data. Obtain via transport.Request.RawRequest():
if raw, ok := req.RawRequest().(wing.RawRequest); ok {
fd := raw.Fd()
}
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func (*Transport) ListenAndServe ¶
func (*Transport) SetRouteFeather ¶
SetRouteFeather implements transport.FeatherConfigurator.