flowcontrol

package
v1.5.14 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package flowcontrol implements a client side flow control mechanism

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
}

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
}

func NewClientNode

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

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
}

func NewServerNode

func NewServerNode(params *ServerParams) *ServerNode

func (*ServerNode) AssignRequest

func (peer *ServerNode) AssignRequest(reqID uint64) bool

AssignRequest tries to assign the server node to the given request, guaranteeing that once it returns true, no request will be sent to the node before this one

func (*ServerNode) CanSend

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

CanSend returns the minimum waiting time required before sending a request with the given maximum estimated cost

func (*ServerNode) DeassignRequest

func (peer *ServerNode) DeassignRequest(reqID uint64)

DeassignRequest releases a request assignment in case the planned request is not being sent.

func (*ServerNode) GotReply

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

func (*ServerNode) IsAssigned

func (peer *ServerNode) IsAssigned() bool

IsAssigned returns true if the server node has already been assigned to a request (note that this function returning false does not guarantee that you can assign a request immediately afterwards, its only purpose is to help peer selection)

func (*ServerNode) MustAssignRequest

func (peer *ServerNode) MustAssignRequest(reqID uint64)

MustAssignRequest waits until the node can be assigned to the given request. It is always guaranteed that assignments are released in a short amount of time.

func (*ServerNode) SendRequest

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

blocks until request can be sent

type ServerParams

type ServerParams struct {
	BufLimit, MinRecharge uint64
}

Jump to

Keyboard shortcuts

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