Version: v0.1.0 Latest Latest

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 8 Imported by: 0




This section is empty.


View Source
var (
	// ErrConnectorUnavailable is returned when the CLI cannot connect to a
	// Connector.
	ErrConnectorUnavailable = errors.New("connector unavailable")

	// DefaultConnectorAddress is the default address of a Connector.
	DefaultConnectorAddress = "localhost:8000"


This section is empty.


type Factory

type Factory struct {
	Context          context.Context
	ConnectorAddress string
	ConnectTimeout   time.Duration
	TestListener     *bufconn.Listener
	// contains filtered or unexported fields

Factory is used by commands to provide common configuration.

func New

func New(opts ...Option) *Factory

New returns a new Factory.

func (*Factory) Connect

func (f *Factory) Connect(ctx context.Context) (*grpc.ClientConn, error)

Connect connects to the Connector service and returns the *grpc.ClientConn. If the connection to the Connector cannot be established within the configured ConnectTimeout Duration, ErrConnectorUnavailable is returned.

type Option

type Option func(*Factory)

Option is a Factory option.

func ConnectTimeout

func ConnectTimeout(d time.Duration) Option

ConnectTimeout returns an Option that specifies the timeout for connecting to a Connector.

func ConnectorAddress

func ConnectorAddress(addr string) Option

ConnectorAddress returns an Option that specifies the address of the Connector service.

func Context

func Context(ctx context.Context) Option

Context returns an Option that sets the Context of a Factory.

func TestListener

func TestListener(lis *bufconn.Listener) Option

TestListener returns an Option that provides a Factory with a *bufconn.Listener. When connecting to a Connector, Factory will use the Listener to dial the gRPC server instead of using the ConnectorAddress.

Source Files

Jump to

Keyboard shortcuts

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