sourceiphash

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sourceiphash provides a balancer based on the source-ip hash.

Index

Constants

This section is empty.

Variables

View Source
var GetSourceIP func(ctx context.Context, req any) (netip.Addr, error)

GetSourceIP is the default function to get the source ip of the request.

Functions

This section is empty.

Types

type Balancer

type Balancer struct {
	// GetSourceAddr is used to get the source address.
	//
	// If nil, use GetSourceIP or defaults.GetClientIP insead.
	GetSourceIP func(ctx context.Context, req any) (netip.Addr, error)
	// contains filtered or unexported fields
}

Balancer implements the balancer based on the source-ip hash.

func NewBalancer

func NewBalancer(policy string) *Balancer

NewBalancer returns a new balancer based on the source-ip hash with the policy name.

If policy is empty, use "sourceip_hash" instead.

func (*Balancer) Forward

func (b *Balancer) Forward(c context.Context, r any, eps *loadbalancer.Static) (any, error)

Forward forwards the request to one of the backend endpoints.

func (*Balancer) Policy

func (b *Balancer) Policy() string

Policy returns the policy of the balancer.

Jump to

Keyboard shortcuts

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