roundrobin

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: MIT Imports: 12 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Spec

Spec returns a configuration specification for the round-robin peer list implementation, making it possible to select the least recently chosen peer with transports that use outbound peer list configuration (like HTTP).

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

This enables the round-robin peer list:

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

Types

type List

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

List is a PeerList which rotates which peers are to be selected in a circle

func New

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

New creates a new round robin PeerList

func (*List) Choose

func (pl *List) Choose(ctx context.Context, req *transport.Request) (peer.Peer, func(error), error)

Choose selects the next available peer in the round robin

func (*List) Introspect

func (pl *List) Introspect() introspection.ChooserStatus

Introspect returns a ChooserStatus with a summary of the Peers.

func (*List) IsRunning

func (pl *List) IsRunning() bool

IsRunning returns whether the peer list is running.

func (*List) NotifyStatusChanged

func (pl *List) NotifyStatusChanged(pid peer.Identifier)

NotifyStatusChanged when the peer's status changes

func (*List) Start

func (pl *List) Start() error

Start notifies the List that requests will start coming

func (*List) Stop

func (pl *List) Stop() error

Stop notifies the List that requests will stop coming

func (*List) Update

func (pl *List) Update(updates peer.ListUpdates) error

Update applies the additions and removals of peer Identifiers to the list it returns a multi-error result of every failure that happened without circuit breaking due to failures.

type ListOption

type ListOption func(*listConfig)

ListOption customizes the behavior of a roundrobin list.

func Capacity

func Capacity(capacity int) ListOption

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

Defaults to 10.

Jump to

Keyboard shortcuts

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