middleware

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWouldBlock = errors.New("would block")

ErrWouldBlock is an error that indicates a WithNoBlocking request failed due to blocking.

Functions

func CanBlock

func CanBlock(opts ...grpc.CallOption) bool

CanBlock is a function that allows the P2P system to check for the existence of the WithNoBlocking CallOption to determine request specific blocking policy.

func SetPeer

func SetPeer(p PeerClient, opts ...grpc.CallOption)

SetPeer allows the P2PBus to set the peer reference on a grpc.CallOption.

func WithNoBlocking

func WithNoBlocking() grpc.CallOption

WithNoBlocking generates a grpc.CallOption that is honored by the methods of the P2P system such that any request that contains this CallOption will not block while trying to be passed to the work buffers. If the call would block then an error should be raised.

Types

type PeerCallOption

type PeerCallOption struct {
	*grpc.EmptyCallOption
	Peer func() PeerClient
}

PeerCallOption allows a caller of a P2P Get method to receive a reference to the P2PClient that handled the call for the purpose of feedback.

func NewPeerInterceptor

func NewPeerInterceptor() *PeerCallOption

NewPeerInterceptor is a function that builds a grpc.CallOption that will return a peer ref to the caller.

func (*PeerCallOption) CallOption

func (opt *PeerCallOption) CallOption() grpc.CallOption

CallOption returns the PeerCallOption as a grpc.CallOption.

type PeerClient

type PeerClient interface {
	interfaces.P2PClient
	Feedback(int)
}

PeerClient is an extension of the interfaces.P2PClient to include the Feedback method for use by Get type requests on the P2P methods.

Jump to

Keyboard shortcuts

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