fakevtctlclient

package
v2.2.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fakevtctlclient contains a fake for the vtctlclient interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeLoggerEventStreamingClient

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

FakeLoggerEventStreamingClient is the base for the fakes for the vtctlclient and vtworkerclient. It allows to register a (multi-)line string for a given command and return the result as channel which streams it back.

func NewFakeLoggerEventStreamingClient

func NewFakeLoggerEventStreamingClient() *FakeLoggerEventStreamingClient

NewFakeLoggerEventStreamingClient creates a new fake.

func (*FakeLoggerEventStreamingClient) RegisterResult

func (f *FakeLoggerEventStreamingClient) RegisterResult(args []string, output string, err error) error

RegisterResult registers for a given command (args) the result which the fake should return. Once the result was returned, it will be automatically deregistered.

func (*FakeLoggerEventStreamingClient) RegisterResultForAddr

func (f *FakeLoggerEventStreamingClient) RegisterResultForAddr(addr string, args []string, output string, err error) error

RegisterResultForAddr is identical to RegisterResult but also expects that the client did dial "addr" as server address.

func (*FakeLoggerEventStreamingClient) RegisteredCommands

func (f *FakeLoggerEventStreamingClient) RegisteredCommands() []string

RegisteredCommands returns a list of commands which are currently registered. This is useful to check that all registered results have been consumed.

func (*FakeLoggerEventStreamingClient) StreamResult

func (f *FakeLoggerEventStreamingClient) StreamResult(addr string, args []string) (logutil.EventStream, error)

StreamResult returns an EventStream which streams back a registered result as logging events. "addr" is the server address which the client dialed and may be empty.

type FakeVtctlClient

type FakeVtctlClient struct {
	*FakeLoggerEventStreamingClient
}

FakeVtctlClient is a fake which implements the vtctlclient interface. The fake can be used to return a specific result for a given command. If the command is not registered, an error will be thrown.

func NewFakeVtctlClient

func NewFakeVtctlClient() *FakeVtctlClient

NewFakeVtctlClient creates a FakeVtctlClient struct.

func (*FakeVtctlClient) Close

func (f *FakeVtctlClient) Close()

Close is part of the vtctlclient interface.

func (*FakeVtctlClient) ExecuteVtctlCommand

func (f *FakeVtctlClient) ExecuteVtctlCommand(ctx context.Context, args []string, actionTimeout time.Duration) (logutil.EventStream, error)

ExecuteVtctlCommand is part of the vtctlclient interface.

func (*FakeVtctlClient) FakeVtctlClientFactory

func (f *FakeVtctlClient) FakeVtctlClientFactory(addr string) (vtctlclient.VtctlClient, error)

FakeVtctlClientFactory always returns the current instance.

Jump to

Keyboard shortcuts

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