connector

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToStart is returned when the daemon process cannot be started
	ErrFailedToStart = errors.New("daemon could not be started")
	// ErrVersionMismatch is returned when the daemon process was spawned by a different version than the connecting client
	ErrVersionMismatch = errors.New("daemon version does not match client version")

	// ErrTooManyAttempts is returned when the client fails to connect too many times
	ErrTooManyAttempts = errors.New("reached maximum number of attempts contacting daemon")
	// ErrDaemonNotRunning is returned when the client cannot contact the daemon and has
	// been instructed not to attempt to start a new daemon
	ErrDaemonNotRunning = errors.New("the daemon is not running")
)

Functions

This section is empty.

Types

type Client

Client represents a connection to the daemon process

type ConnectionError

type ConnectionError struct {
	SockPath turbopath.AbsoluteSystemPath
	PidPath  turbopath.AbsoluteSystemPath
	LogPath  turbopath.AbsoluteSystemPath
	// contains filtered or unexported fields
}

ConnectionError is returned in the error case from connect. It wraps the underlying cause and adds a message with the relevant files for the user to check.

func (*ConnectionError) Error

func (ce *ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (ce *ConnectionError) Unwrap() error

Unwrap allows a connection error to work with standard library "errors" and compatible packages

type Connector

type Connector struct {
	Logger       hclog.Logger
	Bin          string
	Opts         Opts
	SockPath     turbopath.AbsoluteSystemPath
	PidPath      turbopath.AbsoluteSystemPath
	LogPath      turbopath.AbsoluteSystemPath
	TurboVersion string
}

Connector instances are used to create a connection to turbo's daemon process The daemon will be started , or killed and restarted, if necessary

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context) (*Client, error)

Connect attempts to create a connection to a turbo daemon. Retries and daemon restarts are built in. If this fails, it is unlikely to succeed after an automated retry.

type Opts

type Opts struct {
	ServerTimeout time.Duration
	DontStart     bool // if true, don't attempt to start the daemon
	DontKill      bool // if true, don't attempt to kill the daemon
}

Opts is the set of configurable options for the client connection, including some options to be passed through to the daemon process if it needs to be started.

Jump to

Keyboard shortcuts

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