- Add 256-shard lock map for concurrent session routing - Cookie-based session persistence with base64 encoding - TTL expiration with background cleanup goroutine - Support Secure, HttpOnly, SameSite cookie attributes - Fallback to configured balancer when session target unavailable
25 lines
563 B
Go
25 lines
563 B
Go
package loadbalance
|
|
|
|
import "time"
|
|
|
|
type StickyConfig struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Name string `yaml:"name"`
|
|
Expires time.Duration `yaml:"expires"`
|
|
Domain string `yaml:"domain"`
|
|
Path string `yaml:"path"`
|
|
Secure bool `yaml:"secure"`
|
|
HttpOnly bool `yaml:"http_only"`
|
|
SameSite string `yaml:"same_site"`
|
|
}
|
|
|
|
func DefaultStickyConfig() StickyConfig {
|
|
return StickyConfig{
|
|
Name: "lolly_route",
|
|
Expires: time.Hour,
|
|
Path: "/",
|
|
HttpOnly: true,
|
|
SameSite: "Lax",
|
|
}
|
|
}
|