priority

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package priority implements the priority protocol that resolves arbitrary cluster wide priorities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consensus

type Consensus interface {
	Propose(ctx context.Context, slot int64, result *pbv1.PriorityResult) error
	Subscribe(func(ctx context.Context, slot int64, result *pbv1.PriorityResult) error)
}

type Prioritiser

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

Prioritiser resolves cluster wide priorities.

func NewForT

func NewForT(_ *testing.T, transport Transport,
	consensus Consensus, msgProvider msgProvider, msgValidator msgValidator,
	consensusTimeout time.Duration, tickerProvider tickerProvider,
) *Prioritiser

NewForT returns a new prioritiser for testing.

func (*Prioritiser) Prioritise

func (p *Prioritiser) Prioritise(slot int64)

Prioritise starts a new prioritisation round for the provided slot.

func (*Prioritiser) Run

func (p *Prioritiser) Run(ctx context.Context) error

Run runs the prioritiser until the context is cancelled. Note this will panic if called multiple times.

func (*Prioritiser) Subscribe

func (p *Prioritiser) Subscribe(topic string, fn subscriber)

Subscribe registers a prioritiser output subscriber function. This is not thread safe and MUST NOT be called after Run.

type Transport

type Transport interface {
	// SendReceive sends the request to the peer and returns a single response.
	SendReceive(
		ctx context.Context,
		peer peer.ID,
		req, resp proto.Message,
		protocols ...protocol.ID) bool

	// ReceiveSend registers a callback function that will be invoked when peers
	// send requests, replying with this peer's response.
	ReceiveSend(
		zeroReq func() proto.Message,
		callback func(ctx context.Context, peer peer.ID, request proto.Message) (proto.Message, error),
		protocols ...protocol.ID)
}

Transport abstracts sending and receiving libp2p protobuf messages.

Jump to

Keyboard shortcuts

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