requester

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: AGPL-3.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultRequestInterval is the time interval that requester engine tries requesting chunk data packs.
	DefaultRequestInterval = 1000 * time.Millisecond

	// DefaultBackoffMultiplier is the base of exponent in exponential backoff multiplier for backing off requests for chunk data packs.
	DefaultBackoffMultiplier = float64(2)

	// DefaultBackoffMinInterval is the minimum time interval a chunk data pack request waits before dispatching.
	DefaultBackoffMinInterval = 1000 * time.Millisecond

	// DefaultBackoffMaxInterval is the maximum time interval a chunk data pack request waits before dispatching.
	DefaultBackoffMaxInterval = 1 * time.Minute

	// DefaultRequestTargets is the  maximum number of execution nodes a chunk data pack request is dispatched to.
	DefaultRequestTargets = 2
)

Variables

This section is empty.

Functions

func RetryAfterQualifier

func RetryAfterQualifier(_ uint64, lastAttempt time.Time, retryAfter time.Duration) bool

RetryAfterQualifier only qualifies a chunk request if its retryAfter duration has been elapsed since the last time this request has been dispatched.

Types

type Engine

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

Engine implements a ChunkDataPackRequester that is responsible of receiving chunk data pack requests, dispatching it to the execution nodes, receiving the requested chunk data pack from execution nodes, and passing it to the registered handler.

func New

func New(log zerolog.Logger,
	state protocol.State,
	net network.Network,
	tracer module.Tracer,
	metrics module.VerificationMetrics,
	pendingRequests mempool.ChunkRequests,
	retryInterval time.Duration,
	reqQualifierFunc RequestQualifierFunc,
	reqUpdaterFunc mempool.ChunkRequestHistoryUpdaterFunc,
	requestTargets uint64) (*Engine, error)

func (*Engine) Done

func (e *Engine) Done() <-chan struct{}

Done terminates the engine and returns a channel that is closed when the termination is done

func (*Engine) Process

func (e *Engine) Process(channel channels.Channel, originID flow.Identifier, event interface{}) error

Process processes the given event from the node with the given origin ID in a blocking manner. It returns the potential processing error when done.

func (*Engine) ProcessLocal

func (e *Engine) ProcessLocal(event interface{}) error

ProcessLocal processes an event originating on the local node.

func (*Engine) Ready

func (e *Engine) Ready() <-chan struct{}

Ready initializes the engine and returns a channel that is closed when the initialization is done.

func (*Engine) Request

func (e *Engine) Request(request *verification.ChunkDataPackRequest)

Request receives a chunk data pack request and adds it into the pending requests mempool.

func (*Engine) Submit

func (e *Engine) Submit(channel channels.Channel, originID flow.Identifier, event interface{})

Submit submits the given event from the node with the given origin ID for processing in a non-blocking manner. It returns instantly and logs a potential processing error internally when done.

func (*Engine) SubmitLocal

func (e *Engine) SubmitLocal(event interface{})

SubmitLocal submits an event originating on the local node.

func (*Engine) WithChunkDataPackHandler

func (e *Engine) WithChunkDataPackHandler(handler fetcher.ChunkDataPackHandler)

type RequestQualifierFunc

type RequestQualifierFunc func(attempts uint64, lastRequested time.Time, retryAfter time.Duration) bool

RequestQualifierFunc is a function type that on receiving the number of attempts a chunk has been requested with, the last time it has been requested, and the duration at which the chunk can be retried after, returns either true or false.

The return value of this function determines whether the chunk request can be dispatched to the network.

func MaxAttemptQualifier

func MaxAttemptQualifier(maxAttempts uint64) RequestQualifierFunc

MaxAttemptQualifier only qualifies a chunk request if it has been requested less than the specified number of attempts.

Jump to

Keyboard shortcuts

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