Documentation ¶
Index ¶
- Variables
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Connect(ctx context.Context) error
- func (c *Connection) Read(p []byte) (n int, err error)
- func (c *Connection) WaitForStateChange(ctx context.Context, sourceState State) (state State, changed bool)
- func (c *Connection) Write(p []byte) (n int, err error)
- type ConnectionConfig
- type ConnectionState
- type Ssh
- type SshConfig
- type State
- type Tcp
- type TcpConfig
- type Transport
Constants ¶
This section is empty.
Variables ¶
var WriteTimeoutError = errors.New("write timed out waiting for connection")
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a connection to another system, and implements Transport, keeping a ConnectionState for handling reconnects, etc...
func NewConnection ¶
func NewConnection(conf ConnectionConfig, bo backoff.BackOff, dial func() error, rwc io.ReadWriteCloser) *Connection
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) WaitForStateChange ¶
type ConnectionConfig ¶
type ConnectionConfig struct { // Timeout is the dial timeout when attempting connection, defaults to 15s Timeout jsontypes.Duration // ReadTimeout is the timeout used when attempting to read, defaults to 0 ReadTimeout jsontypes.Duration // WriteTimeout is the timeout used when attempting to write, defaults to 15s WriteTimeout jsontypes.Duration }
type ConnectionState ¶
type ConnectionState struct {
// contains filtered or unexported fields
}
ConnectionState stores a State and provides methods for subscribing to changes to the state
func NewConnectionState ¶
func NewConnectionState() *ConnectionState
NewConnectionState creates a new ConnectionState
func (*ConnectionState) WaitForStateChange ¶
func (c *ConnectionState) WaitForStateChange(ctx context.Context, sourceState State) (state State, changed bool)
WaitForStateChange waits until the State changes from sourceState or ctx expires. Changed is true returned in former case and false in latter.
type Ssh ¶
type Ssh struct { *Connection // contains filtered or unexported fields }
type SshConfig ¶
type SshConfig struct { ConnectionConfig // Ip is the IP address or hostname of the endpoint Ip string // Port is the port number to connect to, defaults to 22 Port int Username string Password string IgnoreHostKey bool }
SshConfig is used to configure an Ssh transport
type Tcp ¶
type Tcp struct { *Connection // contains filtered or unexported fields }
Tcp implements Transport, back by a tcp connection. Reconnecting is handled automatically, with an exponential backoff for retries.
type TcpConfig ¶
type TcpConfig struct { ConnectionConfig // Ip is the IP address or hostname of the endpoint Ip string // Port is the port number to connect to Port int }
TcpConfig is used to configure a Tcp transport
type Transport ¶
type Transport interface { io.ReadWriteCloser Connect(ctx context.Context) error WaitForStateChange(ctx context.Context, sourceState State) (state State, changed bool) }
Transport presents a way to communicate with another system over arbitrary protocols such as those built on TCP for an example usage, see cmd/tools/tcp-conn-test