upstream

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Name     string `json:"name"`
	Chain    string `json:"chain"`
	Provider string `json:"provider"`
	Endpoint string `json:"endpoint"`
	Protocol string `json:"protocol"`

	RateLimiter *rate.Limiter
	// contains filtered or unexported fields
}

Node main node struct

func NewNode

func NewNode(node *config.Node) (*Node, error)

NewNode create new node

func (*Node) AverageResponseTime

func (n *Node) AverageResponseTime() time.Duration

AverageResponseTime average response time of this node

func (*Node) HealthCheck

func (n *Node) HealthCheck()

HealthCheck a dummy healthcheck (it just recovers for now)

func (*Node) IsHealthy

func (n *Node) IsHealthy() bool

IsHealthy check if node can accept request

func (*Node) Load

func (n *Node) Load() int64

Load get load on that server

func (*Node) NodeID

func (n *Node) NodeID() string

NodeID a unique id for that particular node

func (*Node) ProviderName

func (n *Node) ProviderName() string

ProviderName node provider name

func (*Node) ServeHTTP

func (n *Node) ServeHTTP(ctx *fasthttp.RequestCtx) (upstreamTook time.Duration, err error)

ServeHTTP server http (actual proxy) through this node upstreamTook is only for the upstream request, not total (body reading & writing back to the client etc) it can be misleading when you got an error, so, count success only for accurate latency

func (*Node) SetHealthy

func (n *Node) SetHealthy(healthy bool)

SetHealthy set up/down the node.

func (*Node) ToPromLabels

func (n *Node) ToPromLabels() prometheus.Labels

ToPromLabels return prometheus labels for the node

func (*Node) TotalRequest

func (n *Node) TotalRequest() uint64

TotalRequest total request done to this node so far

type Upstream

type Upstream struct {
	Balancer *balancer.Balancer
}

Upstream main upstream contains multiple upstreams in a balancer

Jump to

Keyboard shortcuts

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