responseassembler

package
v0.10.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0, MIT Imports: 12 Imported by: 3

Documentation

Overview

Package responseassembler assembles responses that are queued for sending in outgoing messages

The response assembler's Transaction method allows a caller to specify response actions that will go into a single libp2p2 message. The response assembler will also deduplicate blocks that have already been sent over the network in a previous message

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerMessageHandler

type PeerMessageHandler interface {
	AllocateAndBuildMessage(p peer.ID, blkSize uint64, buildResponseFn func(*gsmsg.Builder), notifees []notifications.Notifee)
}

PeerMessageHandler is an interface that can queue a response for a given peer to go out over the network If blkSize > 0, message building may block until enough memory has been freed from the queues to allocate the message.

type ResponseAssembler

type ResponseAssembler struct {
	*peermanager.PeerManager
	// contains filtered or unexported fields
}

ResponseAssembler manages assembling responses to go out over the network in libp2p messages

func New

func New(ctx context.Context, peerHandler PeerMessageHandler) *ResponseAssembler

New generates a new ResponseAssembler for sending responses

func (*ResponseAssembler) DedupKey

func (ra *ResponseAssembler) DedupKey(p peer.ID, requestID graphsync.RequestID, key string)

DedupKey indicates that outgoing blocks should be deduplicated in a seperate bucket (only with requests that share supplied key string)

func (*ResponseAssembler) IgnoreBlocks

func (ra *ResponseAssembler) IgnoreBlocks(p peer.ID, requestID graphsync.RequestID, links []ipld.Link)

IgnoreBlocks indicates that a list of keys should be ignored when sending blocks

func (*ResponseAssembler) SkipFirstBlocks added in v0.10.0

func (ra *ResponseAssembler) SkipFirstBlocks(p peer.ID, requestID graphsync.RequestID, skipFirstBlocks int64)

SkipFirstBlocks tells the assembler for the given request to not send the first N blocks

func (*ResponseAssembler) Transaction

func (ra *ResponseAssembler) Transaction(p peer.ID, requestID graphsync.RequestID, transaction Transaction) error

Transaction builds a response, and queues it for sending in the next outgoing message

type ResponseBuilder

type ResponseBuilder interface {
	// SendResponse adds a response to this transaction.
	SendResponse(
		link ipld.Link,
		data []byte,
	) graphsync.BlockData

	// SendExtensionData adds extension data to the transaction.
	SendExtensionData(graphsync.ExtensionData)

	// ClearRequest removes all tracking for this request.
	ClearRequest()

	// FinishRequest completes the response to a request.
	FinishRequest() graphsync.ResponseStatusCode

	// FinishWithError end the response due to an error
	FinishWithError(status graphsync.ResponseStatusCode)

	// PauseRequest temporarily halts responding to the request
	PauseRequest()

	// AddNotifee adds a notifee to be notified about the response to request.
	AddNotifee(notifications.Notifee)
}

ResponseBuilder is a limited interface for assembling responses inside a transaction, so that they are included in the same message on the protocol

type Transaction

type Transaction func(ResponseBuilder) error

Transaction is a series of operations that should be send together in a single response

Jump to

Keyboard shortcuts

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