connection

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateConnActive = "CONN_ACTIVE" // connected, broker requesting metrics
	StateConnIdle   = "CONN_IDLE"   // connected, no requests
	StateNew        = "NEW"         // new, no attempt to connect yet
	StateError      = "ERROR"       // connection is erroring
	CommandConnect  = "CONNECT"     // Connect command, must be followed by a request payload
	CommandReset    = "RESET"       // Reset command, resets the connection

	// NOTE: TBD, make some of these user-configurable
	CommTimeoutSeconds   = 10    // seconds, when communicating with noit
	DialerTimeoutSeconds = 15    // seconds, establishing connection
	MetricTimeoutSeconds = 50    // seconds, when communicating with agent
	MaxDelaySeconds      = 10    // maximum amount of delay between attempts
	MaxRequests          = -1    // max requests from broker before resetting connection, -1 = unlimited
	MaxPayloadLen        = 65529 // max unsigned short - 6 (for header)
	MaxCommTimeouts      = 6     // multiply by commTimeout, ensure >(broker polling interval) otherwise conn reset loop
	MinDelayStep         = 1     // minimum seconds to add on retry
	MaxDelayStep         = 7     // maximum seconds to add on retry
	ConfigRetryLimit     = 3     // if failed attempts > limit, force check reconfig (see if broker configuration changed)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	State           string
	LastRequestTime *time.Time

	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(parentLogger zerolog.Logger, agentAddress string, cfg *check.ReverseConfig) (*Connection, error)

func (*Connection) Start

func (c *Connection) Start(ctx context.Context) error

Start the reverse connection to the broker

type OpError

type OpError struct {
	Err          string
	Fatal        bool
	RefreshCheck bool
	OrigErr      error
}

func (*OpError) Error

func (e *OpError) Error() string

Jump to

Keyboard shortcuts

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