randpeer

package
v1.42.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Spec

Spec returns a configuration specification for the random peer list implementation, making it possible to select a random peer with transports that use outbound peer list configuration (like HTTP).

cfg := yarpcconfig.New()
cfg.MustRegisterPeerList(random.Spec())

This enables the random peer list:

outbounds:
  otherservice:
    unary:
      http:
        url: https://host:port/rpc
        random:
          peers:
            - 127.0.0.1:8080
            - 127.0.0.1:8081

func SpecWithOptions

func SpecWithOptions(options ...ListOption) yarpcconfig.PeerListSpec

SpecWithOptions accepts additional list constructor options.

Types

type Configuration

type Configuration struct {
	Capacity *int `config:"capacity"`
	FailFast bool `config:"failFast"`
}

Configuration descripes how to build a random peer list.

type List

type List struct {
	*abstractlist.List
}

List is a PeerList that rotates which peers are to be selected randomly

func New

func New(transport peer.Transport, opts ...ListOption) *List

New creates a new random peer list.

type ListOption

type ListOption interface {
	// contains filtered or unexported methods
}

ListOption customizes the behavior of a random list.

func Capacity

func Capacity(capacity int) ListOption

Capacity specifies the default capacity of the underlying data structures for this list.

Defaults to 10.

func FailFast

func FailFast() ListOption

FailFast indicates that the peer list should not wait for a peer to become available when choosing a peer.

This option is preferrable when the better failure mode is to retry from the origin, since another proxy instance might already have a connection.

func Logger

func Logger(logger *zap.Logger) ListOption

Logger specifies a logger.

func Seed

func Seed(seed int64) ListOption

Seed specifies the seed for generating random choices.

func Source

func Source(source rand.Source) ListOption

Source is a source of randomness for the peer list.

Jump to

Keyboard shortcuts

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