Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Spec

    Spec returns a configuration specification for the direct peer chooser. The chooser uses transport.Request#ShardKey as the peer dentifier.

    cfg := yarpcconfig.New()
    cfg.MustRegisterPeerChooser(direct.Spec())
    

    This enables the direct chooser:

    outbounds:
      destination-service:
        grpc:
          direct: {}
    

    Types

    type Chooser

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

      Chooser is a peer.Chooser that returns the peer identified by transport.Request#ShardKey, suitable for directly addressing a peer.

      func New

      func New(cfg Configuration, transport peer.Transport, opts ...ChooserOption) (*Chooser, error)

        New creates a new direct peer chooser.

        func (*Chooser) Choose

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

          Choose uses the peer identifier set as the transport.Request#ShardKey to return the peer.

          func (*Chooser) IsRunning

          func (c *Chooser) IsRunning() bool

            IsRunning statisfies the peer.Chooser interface.

            func (*Chooser) Start

            func (c *Chooser) Start() error

              Start statisfies the peer.Chooser interface.

              func (*Chooser) Stop

              func (c *Chooser) Stop() error

                Stop statisfies the peer.Chooser interface.

                type ChooserOption

                type ChooserOption func(*chooserOptions)

                  ChooserOption customizes the behavior of the peer chooser.

                  func Logger

                  func Logger(logger *zap.Logger) ChooserOption

                    Logger sets the logger for the chooser.

                    type Configuration

                    type Configuration struct{}

                      Configuration describes how to build a direct peer chooser.