flowcontrol

package
v0.0.0-...-ac8b7ce Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Overview

* 流量控制

Package flowcontrol implements a client side flow control mechanism

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientManager

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

这是一个 轻节点的 client 端的管理器

func NewClientManager

func NewClientManager(rcTarget, maxSimReq, maxRcSum uint64) *ClientManager

func (*ClientManager) Stop

func (self *ClientManager) Stop()

type ClientNode

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

todo 流量控制 client 这是实现一个 轻节点链接的 client端 (就是一个轻节点)

func NewClientNode

func NewClientNode(cm *ClientManager, params *ServerParams) *ClientNode

* 创建一个 light 模式的client

func (*ClientNode) AcceptRequest

func (peer *ClientNode) AcceptRequest() (uint64, bool)

func (*ClientNode) Remove

func (peer *ClientNode) Remove(cm *ClientManager)

func (*ClientNode) RequestProcessed

func (peer *ClientNode) RequestProcessed(cost uint64) (bv, realCost uint64)

type ServerNode

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

todo 流量控制 Server 这是实现一个轻节点链接的 Server端 (一个全节点) 每个server 挂着多个client recharge,代表这个server所能服务的请求能力,以及server运维者可以通过这个限制进行使用

func NewServerNode

func NewServerNode(params *ServerParams) *ServerNode

func (*ServerNode) CanSend

func (peer *ServerNode) CanSend(maxCost uint64) (time.Duration, float64)

CanSend returns the minimum waiting time required before sending a request with the given maximum estimated cost. Second return value is the relative estimated buffer level after sending the request (divided by BufLimit).

CanSend 返回以给定的最大估计成本发送请求之前所需的最短等待时间。 第二个返回值是发送请求后的相对估计缓冲区级别(由BufLimit划分)。

func (*ServerNode) GotReply

func (peer *ServerNode) GotReply(reqID, bv uint64)

GotReply adjusts estimated buffer value according to the value included in the latest request reply.

* GotReply: 根据最新请求回复中包含的值来调整估计的缓冲区值。

func (*ServerNode) QueueRequest

func (peer *ServerNode) QueueRequest(reqID, maxCost uint64)

QueueRequest should be called when the request has been assigned to the given server node, before putting it in the send queue. It is mandatory that requests are sent in the same order as the QueueRequest calls are made.

* QueueRequest: QueueRequest 将在 req 被分配给定的 server时,在加入发送队列之前被调用. 必须以与发出QueueRequest调用相同的顺序发送请求。

type ServerParams

type ServerParams struct {

	// 缓存的限制,  最低恢复速度总和
	BufLimit, MinRecharge uint64
}

握手时的重要参数 recharge,代表这个server所能服务的请求能力,以及server运维者可以通过这个限制进行使用 todo recharge: 恢复速度总和 (恢复什么, 恢复 镜像令牌桶 buffer, 也就是说当具备更多的令牌 <buffer> 时才可以被请求)

Jump to

Keyboard shortcuts

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