messagequeue

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0, MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator added in v0.6.0

type Allocator interface {
	AllocateBlockMemory(p peer.ID, amount uint64) <-chan error
	ReleasePeerMemory(p peer.ID) error
	ReleaseBlockMemory(p peer.ID, amount uint64) error
}

type Builder added in v0.11.4

type Builder struct {
	*gsmsg.Builder
	// contains filtered or unexported fields
}

Builder wraps a message builder with additional functions related to metadata and notifications in the message queue

func NewBuilder added in v0.11.4

func NewBuilder(ctx context.Context, topic Topic) *Builder

NewBuilder sets up a new builder for the given topic

func (*Builder) AddBlockData added in v0.11.4

func (b *Builder) AddBlockData(requestID graphsync.RequestID, blockData graphsync.BlockData)

AddBlockData add the given block metadata for this message to pass into notifications

func (*Builder) BlockData added in v0.11.4

func (b *Builder) BlockData() map[graphsync.RequestID][]graphsync.BlockData

BlockData inspects current block data

func (*Builder) Context added in v0.12.0

func (b *Builder) Context() context.Context

func (*Builder) ResponseStreams added in v0.11.4

func (b *Builder) ResponseStreams() map[graphsync.RequestID]io.Closer

ResponseStreams inspect current response stream state

func (*Builder) ScrubResponses added in v0.11.4

func (b *Builder) ScrubResponses(requestIDs []graphsync.RequestID) uint64

ScrubResponse removes the given responses from the message and metadata

func (*Builder) SetResponseStream added in v0.11.4

func (b *Builder) SetResponseStream(requestID graphsync.RequestID, stream io.Closer)

SetResponseStream sets the given response stream to close should the message fail to send

func (*Builder) SetSubscriber added in v0.11.4

func (b *Builder) SetSubscriber(requestID graphsync.RequestID, subscriber notifications.Subscriber)

SetSubscriber sets the given subscriber to get notified as events occur for this message

func (*Builder) Subscribers added in v0.11.4

func (b *Builder) Subscribers() map[graphsync.RequestID]notifications.Subscriber

Subscribers inspect current subscribers

type Event added in v0.3.0

type Event struct {
	Name     EventName
	Err      error
	Metadata Metadata
}

type EventName added in v0.3.0

type EventName uint64
const (
	Queued EventName = iota
	Sent
	Error
)

type MessageNetwork

type MessageNetwork interface {
	NewMessageSender(context.Context, peer.ID, gsnet.MessageSenderOpts) (gsnet.MessageSender, error)
	ConnectTo(context.Context, peer.ID) error
}

MessageNetwork is any network that can connect peers and generate a message sender.

type MessageQueue

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

MessageQueue implements queue of want messages to send to peers.

func New

func New(ctx context.Context, p peer.ID, network MessageNetwork, allocator Allocator, maxRetries int, sendMessageTimeout time.Duration, onShutdown func(peer.ID)) *MessageQueue

New creats a new MessageQueue.

func (*MessageQueue) AllocateAndBuildMessage added in v0.6.0

func (mq *MessageQueue) AllocateAndBuildMessage(size uint64, buildMessageFn func(*Builder))

AllocateAndBuildMessage allows you to work modify the next message that is sent in the queue. If blkSize > 0, message building may block until enough memory has been freed from the queues to allocate the message.

func (*MessageQueue) Shutdown

func (mq *MessageQueue) Shutdown()

Shutdown stops the processing of messages for a message queue.

func (*MessageQueue) Startup

func (mq *MessageQueue) Startup()

Startup starts the processing of messages, and creates an initial message based on the given initial wantlist.

type Metadata added in v0.11.4

type Metadata struct {
	BlockData     map[graphsync.RequestID][]graphsync.BlockData
	ResponseCodes map[graphsync.RequestID]graphsync.ResponseStatusCode
}

type Topic added in v0.3.0

type Topic uint64

Jump to

Keyboard shortcuts

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