Documentation ¶
Overview ¶
Package yarpctest provides utilities to test YARPC services and clients.
Index ¶
- func FakePeerChooserPreset() config.PeerChooserPreset
- func FakePeerListSpec() config.PeerListSpec
- func FakePeerListUpdaterSpec() config.PeerListUpdaterSpec
- func FakeTransportSpec() config.TransportSpec
- func ListNop(nop string) func(*FakePeerList)
- func NewFakeConfigurator(opts ...config.Option) *config.Configurator
- func UpdaterNop(nop string) func(*FakePeerListUpdater)
- func Watch(u *FakePeerListUpdater)
- type FakeOutbound
- func (o *FakeOutbound) Call(ctx context.Context, req *transport.Request) (*transport.Response, error)
- func (o *FakeOutbound) Chooser() peer.Chooser
- func (o *FakeOutbound) IsRunning() bool
- func (o *FakeOutbound) NopOption() string
- func (o *FakeOutbound) Start() error
- func (o *FakeOutbound) Stop() error
- func (o *FakeOutbound) Transports() []transport.Transport
- type FakeOutboundConfig
- type FakeOutboundOption
- type FakePeer
- type FakePeerList
- type FakePeerListConfig
- type FakePeerListOption
- type FakePeerListUpdater
- type FakePeerListUpdaterConfig
- type FakePeerListUpdaterOption
- type FakeTransport
- func (t *FakeTransport) NewOutbound(c peer.Chooser, opts ...FakeOutboundOption) *FakeOutbound
- func (t *FakeTransport) NopOption() string
- func (t *FakeTransport) ReleasePeer(id peer.Identifier, ps peer.Subscriber) error
- func (t *FakeTransport) RetainPeer(id peer.Identifier, ps peer.Subscriber) (peer.Peer, error)
- type FakeTransportConfig
- type FakeTransportOption
- type OutboundCallable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FakePeerChooserPreset ¶
func FakePeerChooserPreset() config.PeerChooserPreset
FakePeerChooserPreset is a PeerChooserPreset which builds a FakePeerList buind to a FakePeerListUpdater.
func FakePeerListSpec ¶
func FakePeerListSpec() config.PeerListSpec
FakePeerListSpec returns a configurator spec for the fake-list FakePeerList peer selection strategy, suitable for passing to Configurator.MustRegisterPeerList.
func FakePeerListUpdaterSpec ¶
func FakePeerListUpdaterSpec() config.PeerListUpdaterSpec
FakePeerListUpdaterSpec returns a configurator spec for the fake-updater FakePeerListUpdater type, suitable for passing to Configurator.MustRegisterPeerListUpdaterSpec.
func FakeTransportSpec ¶
func FakeTransportSpec() config.TransportSpec
FakeTransportSpec returns a configurator spec for the fake-transport transport type, suitable for passing to Configurator.MustRegisterTransport.
func ListNop ¶
func ListNop(nop string) func(*FakePeerList)
ListNop is a fake option for NewFakePeerList that sets a nop var. It's fake.
func NewFakeConfigurator ¶
func NewFakeConfigurator(opts ...config.Option) *config.Configurator
NewFakeConfigurator returns a configurator with fake-transport, fake-peer-list, and fake-peer-list-updater specs already registered, suitable for testing the configurator.
func UpdaterNop ¶
func UpdaterNop(nop string) func(*FakePeerListUpdater)
UpdaterNop is a fake option for NewFakePeerListUpdater that sets a nop var. It's fake.
func Watch ¶
func Watch(u *FakePeerListUpdater)
Watch is a fake option for NewFakePeerListUpdater that enables "watch". It's fake.
Types ¶
type FakeOutbound ¶
type FakeOutbound struct {
// contains filtered or unexported fields
}
FakeOutbound is a unary outbound for the FakeTransport. It is fake.
func (*FakeOutbound) Call ¶
func (o *FakeOutbound) Call(ctx context.Context, req *transport.Request) (*transport.Response, error)
Call pretends to send a unary RPC, but actually just returns an error.
func (*FakeOutbound) Chooser ¶
func (o *FakeOutbound) Chooser() peer.Chooser
Chooser returns theis FakeOutbound's peer chooser.
func (*FakeOutbound) IsRunning ¶
func (o *FakeOutbound) IsRunning() bool
IsRunning returns whether the fake outbound is running.
func (*FakeOutbound) NopOption ¶
func (o *FakeOutbound) NopOption() string
NopOption returns this FakeOutbound's nopOption. It is fake.
func (*FakeOutbound) Start ¶
func (o *FakeOutbound) Start() error
Start starts the fake outbound and its chooser.
func (*FakeOutbound) Stop ¶
func (o *FakeOutbound) Stop() error
Stop stops the fake outbound and its chooser.
func (*FakeOutbound) Transports ¶
func (o *FakeOutbound) Transports() []transport.Transport
Transports returns the FakeTransport that owns this outbound.
type FakeOutboundConfig ¶
type FakeOutboundConfig struct { config.PeerChooser Nop string `config:"nop,interpolate"` }
FakeOutboundConfig configures the FakeOutbound.
type FakeOutboundOption ¶
type FakeOutboundOption func(*FakeOutbound)
FakeOutboundOption is an option for FakeTransport.NewOutbound.
func NopOutboundOption ¶
func NopOutboundOption(nopOption string) FakeOutboundOption
NopOutboundOption returns an option to set the "nopOption" for a FakeTransport.NewOutbound. The nopOption has no effect exists only to verify that the option was passed, via `FakeOutbound.NopOption()`.
func OutboundCallOverride ¶
func OutboundCallOverride(callable OutboundCallable) FakeOutboundOption
OutboundCallOverride returns an option to set the "callOverride" for a FakeTransport.NewOutbound. This can be used to set the functionality for the FakeOutbound's `Call` function.
type FakePeer ¶
type FakePeer struct {
// contains filtered or unexported fields
}
FakePeer is a fake peer with an identifier.
func (*FakePeer) Identifier ¶
Identifier returns the fake peer identifier.
type FakePeerList ¶
FakePeerList is a fake peer list.
func NewFakePeerList ¶
func NewFakePeerList(opts ...FakePeerListOption) *FakePeerList
NewFakePeerList returns a fake peer list.
func (*FakePeerList) Choose ¶
func (c *FakePeerList) Choose(ctx context.Context, req *transport.Request) (peer.Peer, func(error), error)
Choose pretends to choose a peer, but actually always returns an error. It's fake.
func (*FakePeerList) Nop ¶
func (c *FakePeerList) Nop() string
Nop returns the Peer List's nop variable.
func (*FakePeerList) Update ¶
func (c *FakePeerList) Update(up peer.ListUpdates) error
Update pretends to add or remove peers.
type FakePeerListConfig ¶
type FakePeerListConfig struct {
Nop string `config:"nop,interpolate"`
}
FakePeerListConfig configures the FakePeerList.
type FakePeerListOption ¶
type FakePeerListOption func(*FakePeerList)
FakePeerListOption is an option for NewFakePeerList.
type FakePeerListUpdater ¶
FakePeerListUpdater is a fake peer list updater. It doesn't actually update a peer list.
func NewFakePeerListUpdater ¶
func NewFakePeerListUpdater(opts ...FakePeerListUpdaterOption) *FakePeerListUpdater
NewFakePeerListUpdater returns a new FakePeerListUpdater, applying any passed options.
func (*FakePeerListUpdater) Nop ¶
func (u *FakePeerListUpdater) Nop() string
Nop returns the nop variable.
func (*FakePeerListUpdater) Watch ¶
func (u *FakePeerListUpdater) Watch() bool
Watch returns whether the peer list updater was configured to "watch". It is fake.
type FakePeerListUpdaterConfig ¶
type FakePeerListUpdaterConfig struct { FakeUpdater string `config:"fake-updater"` Nop string `config:"nop,interpolate"` Watch bool `config:"watch"` }
FakePeerListUpdaterConfig configures a fake-updater FakePeerListUpdater. It has a fake "watch" property that adds the Watch option for NewFakePeerListUpdater when you build a peer list with this config.
type FakePeerListUpdaterOption ¶
type FakePeerListUpdaterOption func(*FakePeerListUpdater)
FakePeerListUpdaterOption is an option for NewFakePeerListUpdater.
type FakeTransport ¶
FakeTransport is a fake transport.
func NewFakeTransport ¶
func NewFakeTransport(opts ...FakeTransportOption) *FakeTransport
NewFakeTransport returns a fake transport.
func (*FakeTransport) NewOutbound ¶
func (t *FakeTransport) NewOutbound(c peer.Chooser, opts ...FakeOutboundOption) *FakeOutbound
NewOutbound returns a FakeOutbound with a given peer chooser and options.
func (*FakeTransport) NopOption ¶
func (t *FakeTransport) NopOption() string
NopOption returns the configured nopOption. It's fake.
func (*FakeTransport) ReleasePeer ¶
func (t *FakeTransport) ReleasePeer(id peer.Identifier, ps peer.Subscriber) error
ReleasePeer does nothing.
func (*FakeTransport) RetainPeer ¶
func (t *FakeTransport) RetainPeer(id peer.Identifier, ps peer.Subscriber) (peer.Peer, error)
RetainPeer returns a fake peer.
type FakeTransportConfig ¶
type FakeTransportConfig struct {
Nop string `config:"nop,interpolate"`
}
FakeTransportConfig configures the FakeTransport.
type FakeTransportOption ¶
type FakeTransportOption func(*FakeTransport)
FakeTransportOption is an option for NewFakeTransport.
func NopTransportOption ¶
func NopTransportOption(nopOption string) FakeTransportOption
NopTransportOption returns a no-op option for NewFakeTransport. The option exists to verify that options work.