vtworkerclient

package
v2.0.0-beta.1+incompat... Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package vtworkerclient contains the generic client side of the remote vtworker protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFactory

func RegisterFactory(name string, factory Factory)

RegisterFactory allows a client implementation to register itself.

func RunCommandAndWait

func RunCommandAndWait(ctx context.Context, server string, args []string, recv func(*logutilpb.Event)) error

RunCommandAndWait executes a single command on a given vtworker and blocks until the command did return or timed out. Output from vtworker is streamed as logutil.Event messages which have to be consumed by the caller who has to specify a "recv" function.

func UnregisterFactoryForTest

func UnregisterFactoryForTest(name string)

UnregisterFactoryForTest allows to unregister a client implementation from the static map. This function is used by unit tests to cleanly unregister any fake implementations. This way, a test package can use the same name for different fakes and no dangling fakes are left behind in the static factories map after the test.

Types

type Client

type Client interface {
	// ExecuteVtworkerCommand will execute the command remotely.
	// NOTE: ErrFunc should only be checked after the returned channel was closed to avoid races.
	ExecuteVtworkerCommand(ctx context.Context, args []string) (<-chan *logutilpb.Event, ErrFunc, error)

	// Close will terminate the connection. This object won't be
	// used after this.
	Close()
}

Client defines the interface used to send remote vtworker commands

func New

func New(addr string, connectTimeout time.Duration) (Client, error)

New allows a user of the client library to get its implementation.

type ErrFunc

type ErrFunc func() error

ErrFunc is returned by streaming queries to get the error

type Factory

type Factory func(addr string, connectTimeout time.Duration) (Client, error)

Factory functions are registered by client implementations.

Jump to

Keyboard shortcuts

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