forwarder

package
v0.0.0-...-75fa689 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReaderBuffSize is used for bufio reader.
	ReaderBuffSize           = 16 * 1024 // 16K bytes
	DefaultIdleTimeout       = 30 * time.Second
	DefaultConnectTimeout    = 3 * time.Second
	DefaultHeartbeatInterval = 20 * time.Second
)

Variables

View Source
var (
	ErrNoTlsConfig = errors.New("tls config is not exist")
)
View Source
var ErrParseRootCertFailed = errors.New("failed to parse root certificate")

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(logger log.Logger, cfg ClientConfig, handler func(req *logproto.PushRequest)) *Client

func (*Client) Connect

func (c *Client) Connect() (err error)

func (*Client) ConnectTcp

func (c *Client) ConnectTcp() (err error)

func (*Client) IsShutdown

func (c *Client) IsShutdown() bool

IsShutdown client is shutdown or not.

func (*Client) IsStopping

func (c *Client) IsStopping() bool

IsStopping client is stopping or not.

func (*Client) Start

func (c *Client) Start() error

func (*Client) Stop

func (c *Client) Stop()

Stop implements Client

func (*Client) StopNow

func (c *Client) StopNow()

StopNow implements Client

func (*Client) TlsConnect

func (c *Client) TlsConnect() error

type ClientConfig

type ClientConfig struct {
	Host              string        `yaml:"host"`
	Port              int           `yaml:"port"`
	MaxMessageLength  int           `yaml:"max_message_length"`
	ConnectTimeout    time.Duration `yaml:"connect_timeout"`
	IdleTimeout       time.Duration `yaml:"idle_timeout"`
	KeepalivePeriod   time.Duration `yaml:"keepalive_period"` // If it is zero we don't set keepalive
	HeartbeatInterval time.Duration `yaml:"heart_interval"`
	ReconnectInterval time.Duration `yaml:"reconnect_interval"`   // If it is zero we don't reconnect
	TLSConfig         TLSConfig     `yaml:"tls_config,omitempty"` // TLSConfig to use to connect to the targets.
}

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewConn

func NewConn(cfg ConnConfig, logger log.Logger, conn net.Conn, handleClose func(*Conn)) *Conn

func (*Conn) SendEntry

func (c *Conn) SendEntry(entry api.Entry) error

func (*Conn) Start

func (c *Conn) Start()

func (*Conn) Stop

func (c *Conn) Stop()

Stop the Conn.

type ConnConfig

type ConnConfig struct {
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

type EntryItem

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

type Server

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

func New

func New(logger log.Logger, cfg ServerConfig) (*Server, error)

New makes a new Server

func (*Server) Chan

func (s *Server) Chan() chan<- api.Entry

Chan implements Server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

Stop implements Server

func (*Server) StopNow

func (s *Server) StopNow()

StopNow implements Server

type ServerConfig

type ServerConfig struct {
	ForwardEnable          bool          `yaml:"enable"`
	ForwardListenAddress   string        `yaml:"listen_address"`
	ForwardListenPort      int           `yaml:"listen_port"`
	ForwardConnLimit       int           `yaml:"listen_conn_limit"`
	ForwardReadTimeout     time.Duration `yaml:"read_timeout"`
	ForwardWriteTimeout    time.Duration `yaml:"write_timeout"`
	ForwardKeepalivePeriod time.Duration `yaml:"keepalive_period"`
	ForwardTLSConfig       TLSConfig     `yaml:"tls_config,omitempty"`
}

func (*ServerConfig) RegisterFlags

func (cfg *ServerConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

func (*ServerConfig) RegisterFlagsWithPrefix

func (cfg *ServerConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

RegisterFlagsWithPrefix with prefix registers flags where every name is prefixed by prefix. If prefix is a non-empty string, prefix should end with a period.

type TLSConfig

type TLSConfig struct {
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify"`
	TLSCertPath        string `yaml:"cert_file"`
	TLSKeyPath         string `yaml:"key_file"`
}

Jump to

Keyboard shortcuts

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