queryexecutor

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: Apache-2.0, MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const ErrCancelledByCommand = errorString("response cancelled by responder")
View Source
const ErrFirstBlockLoad = errorString("Unable to load first block")

ErrFirstBlockLoad indicates the traversal was unable to load the very first block in the traversal

View Source
const ErrNetworkError = errorString("network error")

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockHooks

type BlockHooks interface {
	ProcessBlockHooks(p peer.ID, request graphsync.RequestData, blockData graphsync.BlockData) hooks.BlockResult
}

BlockHooks is an interface for processing block hooks

type Manager

type Manager interface {
	StartTask(task *peertask.Task, responseTaskChan chan<- ResponseTask)
	GetUpdates(p peer.ID, requestID graphsync.RequestID, updatesChan chan<- []gsmsg.GraphSyncRequest)
	FinishTask(task *peertask.Task, err error)
}

Manager providers an interface to the response manager

type QueryExecutor

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

QueryExecutor is responsible for performing individual requests by executing their traversals

func New

func New(ctx context.Context,
	manager Manager,
	blockHooks BlockHooks,
	updateHooks UpdateHooks,
	responseAssembler ResponseAssembler,
) *QueryExecutor

New creates a new QueryExecutor

func (*QueryExecutor) ExecuteTask

func (qe *QueryExecutor) ExecuteTask(ctx context.Context, pid peer.ID, task *peertask.Task) bool

ExecuteTask takes a single task and executes its traversal it describes. For each block, it checks for signals on the task's ResponseSignals, updates on the QueryExecutor's UpdateHooks, and uses the ResponseAssembler to build and send a response, while also triggering any of the QueryExecutor's BlockHooks. Traversal continues until complete, or a signal or hook suggests we should stop or pause.

type ResponseAssembler

type ResponseAssembler interface {
	Transaction(p peer.ID, requestID graphsync.RequestID, transaction responseassembler.Transaction) error
}

ResponseAssembler is an interface that returns sender interfaces for peer responses.

type ResponseSignals

type ResponseSignals struct {
	PauseSignal  chan struct{}
	UpdateSignal chan struct{}
	ErrSignal    chan error
}

ResponseSignals are message channels to communicate between the manager and the QueryExecutor

type ResponseTask

type ResponseTask struct {
	Empty      bool
	Subscriber *notifications.TopicDataSubscriber
	Ctx        context.Context
	Span       trace.Span
	Request    gsmsg.GraphSyncRequest
	Loader     ipld.BlockReadOpener
	Traverser  ipldutil.Traverser
	Signals    ResponseSignals
}

ResponseTask returns all information needed to execute a given response

type UpdateHooks

type UpdateHooks interface {
	ProcessUpdateHooks(p peer.ID, request graphsync.RequestData, update graphsync.RequestData) hooks.UpdateResult
}

UpdateHooks is an interface for processing update hooks

Jump to

Keyboard shortcuts

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