egress

package
v0.0.0-...-57f4fd1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExponentialDuration

func ExponentialDuration(attempt int) time.Duration

ExponentialDuration returns a duration that grows exponentially with each attempt. It is maxed out at 15 seconds.

Types

type ConnectorOption

type ConnectorOption func(*SyslogConnector)

ConnectorOption allows a syslog connector to be customized.

func WithConstructors

func WithConstructors(constructors map[string]WriterConstructor) ConnectorOption

WithConstructors allows users to configure the constructors which will create syslog network connections. The string key in the constructors map should name the protocol.

func WithDroppedMetrics

func WithDroppedMetrics(metrics map[string]pulseemitter.CounterMetric) ConnectorOption

WithDroppedMetrics allows users to configure the dropped metrics which will be emitted when a syslog writer drops messages

func WithEgressMetrics

func WithEgressMetrics(metrics map[string]pulseemitter.CounterMetric) ConnectorOption

WithEgressMetrics allows users to configure the dropped metrics which will be emitted when a syslog writer drops messages

func WithLogClient

func WithLogClient(logClient LogClient, sourceIndex string) ConnectorOption

WithLogClient returns a ConnectorOption that will set up logging for any information about a binding.

type DialFunc

type DialFunc func(addr string) (net.Conn, error)

DialFunc represents a method for creating a connection, either TCP or TLS.

type DiodeWriter

type DiodeWriter struct {
	// contains filtered or unexported fields
}

func NewDiodeWriter

func NewDiodeWriter(
	ctx context.Context,
	wc WriteCloser,
	alerter gendiodes.Alerter,
	wg WaitGroup,
) *DiodeWriter

func (*DiodeWriter) Write

func (d *DiodeWriter) Write(env *loggregator_v2.Envelope) error

Write writes an envelope into the diode. This can not fail.

type HTTPSWriter

type HTTPSWriter struct {
	// contains filtered or unexported fields
}

func (*HTTPSWriter) Close

func (*HTTPSWriter) Close() error

func (*HTTPSWriter) Write

func (w *HTTPSWriter) Write(env *loggregator_v2.Envelope) error

type LogClient

type LogClient interface {
	EmitLog(message string, opts ...loggregator.EmitLogOption)
}

LogClient is used to emit logs.

type NetworkTimeoutConfig

type NetworkTimeoutConfig struct {
	Keepalive    time.Duration
	DialTimeout  time.Duration
	WriteTimeout time.Duration
}

NetworkTimeoutConfig stores various timeout values.

type RetryDuration

type RetryDuration func(attempt int) time.Duration

RetryDuration calculates a duration based on the number of write attempts.

type RetryWriter

type RetryWriter struct {
	// contains filtered or unexported fields
}

RetryWriter wraps a WriteCloser and will retry writes if the first fails.

func (*RetryWriter) Close

func (r *RetryWriter) Close() error

Close delegates to the syslog writer.

func (*RetryWriter) Write

Write will retry writes unitl maxRetries has been reached.

type SyslogConnector

type SyslogConnector struct {
	// contains filtered or unexported fields
}

SyslogConnector creates the various egress syslog writers.

func NewSyslogConnector

func NewSyslogConnector(
	netConf NetworkTimeoutConfig,
	skipCertVerify bool,
	wg WaitGroup,
	opts ...ConnectorOption,
) *SyslogConnector

NewSyslogConnector configures and returns a new SyslogConnector.

func (*SyslogConnector) Connect

func (w *SyslogConnector) Connect(ctx context.Context, b *v1.Binding) (Writer, error)

Connect returns an egress writer based on the scheme of the binding drain URL.

type TCPWriter

type TCPWriter struct {
	// contains filtered or unexported fields
}

TCPWriter represents a syslog writer that connects over unencrypted TCP. This writer is not meant to be used from multiple goroutines. The same goroutine that calls `.Write()` should be the one that calls `.Close()`.

func (*TCPWriter) Close

func (w *TCPWriter) Close() error

Close tears down any active connections to the drain and prevents reconnect.

func (*TCPWriter) Write

func (w *TCPWriter) Write(env *loggregator_v2.Envelope) error

Write writes an envelope to the syslog drain connection.

type TLSWriter

type TLSWriter struct {
	TCPWriter
}

TLSWriter represents a syslog writer that connects over unencrypted TCP.

type URLBinding

type URLBinding struct {
	Context  context.Context
	AppID    string
	Hostname string
	URL      *url.URL
}

application is identified by AppID and Hostname. The syslog URL is identified by URL.

func (*URLBinding) Scheme

func (u *URLBinding) Scheme() string

Scheme is a convenience wrapper around the *url.URL Scheme field

type WaitGroup

type WaitGroup interface {
	Add(delta int)
	Done()
}

type WriteCloser

type WriteCloser interface {
	Writer
	io.Closer
}

WriteCloser is the interface for all syslog writers.

func NewHTTPSWriter

func NewHTTPSWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	skipCertVerify bool,
	egressMetric pulseemitter.CounterMetric,
) WriteCloser

func NewTCPWriter

func NewTCPWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	skipCertVerify bool,
	egressMetric pulseemitter.CounterMetric,
) WriteCloser

NewTCPWriter creates a new TCP syslog writer.

func NewTLSWriter

func NewTLSWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	skipCertVerify bool,
	egressMetric pulseemitter.CounterMetric,
) WriteCloser

type Writer

type Writer interface {
	Write(*loggregator_v2.Envelope) error
}

Write is the interface for all diode writers.

type WriterConstructor

type WriterConstructor func(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	skipCertVerify bool,
	egressMetric pulseemitter.CounterMetric,
) WriteCloser

WriterConstructor creates syslog connections to https, syslog, and syslog-tls drains

func RetryWrapper

func RetryWrapper(
	wc WriterConstructor,
	r RetryDuration,
	maxRetries int,
	logClient LogClient,
	sourceIndex string,
) WriterConstructor

RetryWrapper wraps a WriterConstructer, allowing it to retry writes.

Jump to

Keyboard shortcuts

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