mod_session_sticky

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultCookieKey       = "bfe_ssbl"
	DefaultMaxAge          = 3600
	DefaultMaskCode        = "defaultmask"
	DefaultStandbyMaskCode = "standbymask"
	DefaultHttpOnly        = false
	DefaultSecure          = false

	MinMaskCodeLen = 4
)

Variables

View Source
var (
	ModSessionStickyKey = "mod_session_sticky_key"

	// StickyRedisKeyPrefix is the Redis key prefix for sticky mapping
	StickyRedisKeyPrefix = "bfe:stickyid:"
)

Functions

func ProductRuleConfCheck

func ProductRuleConfCheck(conf ProductRuleConfFile) error

check productRuleConf

Types

type CacheType

type CacheType int

CacheType defines the cache type for session sticky

const (
	CacheTypeLocal CacheType = iota // local LRU cache
	CacheTypeRedis                  // Redis distributed cache
)

func ParseCacheType

func ParseCacheType(s string) (CacheType, error)

ParseCacheType converts string to CacheType

func (CacheType) String

func (c CacheType) String() string

type ConfModSessionSticky

type ConfModSessionSticky struct {
	Basic struct {
		DataPath  string // path of config data (session sticky)
		CacheSize int    // sticky cache size
		CacheType string // cache type: "local" or "redis"
	}

	// Redis configuration (refer to mod_req_limit)
	Redis struct {
		Bns            string // BNS service name
		ConnectTimeout int    // connect timeout (ms)
		ReadTimeout    int    // read timeout (ms)
		WriteTimeout   int    // write timeout (ms)
		MaxIdle        int    // max idle connections
		MaxActive      int    // max active connections (0 means unlimited)
		Password       string // Redis password
		ExpireSeconds  int    // cache expire time (seconds)
	}

	Log struct {
		OpenDebug bool
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModSessionSticky, error)

ConfLoad loades config from config file

func (*ConfModSessionSticky) Check

func (cfg *ConfModSessionSticky) Check(confRoot string) error

type ModuleSessionState

type ModuleSessionState struct {
	Version *metrics.State
}

type ModuleSessionSticky

type ModuleSessionSticky struct {
	// contains filtered or unexported fields
}

func NewModuleSessionSticky

func NewModuleSessionSticky() *ModuleSessionSticky

func (*ModuleSessionSticky) FindAndCacheStickyRule

func (m *ModuleSessionSticky) FindAndCacheStickyRule(request *bfe_basic.Request, rules *StickyRuleList) *StickyRule

OBSOLETE! find and cache sticky rule which can match request;

func (*ModuleSessionSticky) FindStickyRule

func (m *ModuleSessionSticky) FindStickyRule(request *bfe_basic.Request, rules *StickyRuleList) *StickyRule

find sticky rule which can match request;

func (*ModuleSessionSticky) Init

func (*ModuleSessionSticky) Name

func (m *ModuleSessionSticky) Name() string

type ProductRuleConf

type ProductRuleConf struct {
	Version string       // version of the config
	Config  ProductRules // product rules for sticky
}

func ProductRuleConfLoad

func ProductRuleConfLoad(filename string) (ProductRuleConf, error)

load sticky rule config from file

Returns:
     (ProductRuleConf, error)

type ProductRuleConfFile

type ProductRuleConfFile struct {
	Version *string
	Config  *ProductRulesFile
}

type ProductRuleTable

type ProductRuleTable struct {
	// contains filtered or unexported fields
}

func NewProductRuleTable

func NewProductRuleTable() *ProductRuleTable

func (*ProductRuleTable) Search

func (t *ProductRuleTable) Search(product string) (*StickyRuleList, bool)

func (*ProductRuleTable) Update

func (t *ProductRuleTable) Update(conf ProductRuleConf)

type ProductRules

type ProductRules map[string]*StickyRuleList

type ProductRulesFile

type ProductRulesFile map[string]*StickyRuleFileList // product => list of sticky rules

type RedisSessionData

type RedisSessionData struct {
	Addr       string `json:"addr"`
	Port       int    `json:"port"`
	SubCluster string `json:"sub_cluster"`
	CreatedAt  int64  `json:"created_at"`
}

RedisSessionData is used for JSON serialization when storing in Redis

type RuleType

type RuleType int
const (
	RuleTypeCookie RuleType = iota
	RuleTypeSticky
	RuleTypeMax
)

type SessionStickyData

type SessionStickyData struct {
	// contains filtered or unexported fields
}

type StickyRule

type StickyRule struct {
	Cond                condition.Condition // condition for sticky
	Type                RuleType
	CookieKey           string // cookie key
	Domain              string // cookie domain
	Path                string // cookie path
	MaxAge              int    // max age
	MaskCode            string // active mask code which used to mask original bytes
	StandbyMaskCode     string // stand by mask code which used to mask original bytes
	Header              string // sticky header name
	URIParam            string // sticky uri param name
	Secure              bool
	HttpOnly            bool
	RenewWindow         int    // renew window in seconds
	StickyRequestField  string // JSON field name in request body for sticky ID (e.g., previous_response_id)
	StickyResponseField string // JSON field name in response body for sticky ID (e.g., response_id)
}

type StickyRuleFile

type StickyRuleFile struct {
	Cond                *string // condition string for sticky
	Type                *string // "Cookie" | "Sticky"
	CookieKey           *string // cookie key
	Domain              *string // cookie domain
	Path                *string // cookie path
	MaxAge              *int    // max age
	MaskCode            *string // active mask code which used to mask original bytes
	StandbyMaskCode     *string // stand by mask code which used to mask original bytes
	Header              *string // sticky header name
	URIParam            *string // sticky uri param name
	Secure              *bool
	HttpOnly            *bool
	RenewWindow         *int    // renew window in seconds
	StickyRequestField  *string // JSON field name in request body for sticky ID (e.g., previous_response_id)
	StickyResponseField *string // JSON field name in response body for sticky ID (e.g., response_id)
}

type StickyRuleFileList

type StickyRuleFileList []StickyRuleFile

type StickyRuleList

type StickyRuleList []StickyRule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL