loadbalancer

package
v0.0.0-...-a7bc12e Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameHandler

type NameHandler struct {
	http.Handler

	Name string
}

NameHandler is a http.Handler with a name.

type Sticky

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

Sticky ensures that client consistently interacts with the same HTTP handler by adding a sticky cookie to the response. This cookie allows subsequent requests from the same client to be routed to the same handler enabling session persistence across multiple requests.

func NewSticky

func NewSticky(cookieConfig dynamic.Cookie) *Sticky

NewSticky creates a new sticky instance

func (*Sticky) AddHandler

func (s *Sticky) AddHandler(name string, h http.Handler)

AddHandler adds a http.Handler to the sticky pool

func (*Sticky) StickyHandler

func (s *Sticky) StickyHandler(req *http.Request) (*NameHandler, bool, error)

StickyHandler returns the NameHandler corresponding to the sticky cookie if one It also returns a boolean which indicates if the sticky cookie has to be overwritten because it uses a deprecated hash algorithm

func (*Sticky) WriteStickyCookie

func (s *Sticky) WriteStickyCookie(rw http.ResponseWriter, name string) error

WriteStickyCookie writes a sticky cookie to the response to stick the client to the given handler name.

Directories

Path Synopsis
Package failover 实现故障转移(Failover)机制: 当主后端(handler)不可用或返回特定错误状态码时, 自动将请求转发给备用后端(fallbackHandler); 两个后端都不可用时返回 503 Service Unavailable。
Package failover 实现故障转移(Failover)机制: 当主后端(handler)不可用或返回特定错误状态码时, 自动将请求转发给备用后端(fallbackHandler); 两个后端都不可用时返回 503 Service Unavailable。
Package hrw 实现了 Highest Random Weight (HRW),即 Rendezvous Hashing 一致性哈希负载均衡算法。
Package hrw 实现了 Highest Random Weight (HRW),即 Rendezvous Hashing 一致性哈希负载均衡算法。
Package mirror 实现 HTTP 请求流量镜像(Traffic Mirroring)。
Package mirror 实现 HTTP 请求流量镜像(Traffic Mirroring)。

Jump to

Keyboard shortcuts

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