beats: github.com/elastic/beats/filebeat/inputsource/tcp Index | Files

package tcp

import "github.com/elastic/beats/filebeat/inputsource/tcp"

Index

Package Files

closeref.go config.go conn.go handler.go scan.go server.go

Constants

const Name = "tcp"

Name is the human readable name and identifier.

Variables

var ErrClosed = errors.New("closer is closed")

ErrClosed is returned when the Closer is closed.

var ErrMaxReadBuffer = errors.New("max read buffer reached")

ErrMaxReadBuffer returns when too many bytes was read on the io.Reader

func IsMaxReadBufferErr Uses

func IsMaxReadBufferErr(err error) bool

IsMaxReadBufferErr returns true when the error is ErrMaxReadBuffer

func SplitFunc Uses

func SplitFunc(lineDelimiter []byte) bufio.SplitFunc

SplitFunc allows to create a `bufio.SplitFunc` based on a delimiter provided.

type CloseRef Uses

type CloseRef interface {
    Done() <-chan struct{}
    Err() error
}

CloseRef implements a subset of the context.Context interface and it's use to synchronize the shutdown of multiple go-routines.

type Closer Uses

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

Closer implements a shutdown strategy when dealing with multiples go-routines, it creates a tree of Closer, when you call `Close()` on a parent the `Close()` method will be called on the current closer and any of the childs it may have and will remove the current node from the parent.

NOTE: The `Close()` is reentrant but will propage the close only once.

func NewCloser Uses

func NewCloser(fn CloserFunc) *Closer

NewCloser creates a new Closer.

func WithCloser Uses

func WithCloser(parent *Closer, fn CloserFunc) *Closer

WithCloser wraps a new closer into a child of an existing closer.

func (*Closer) Close Uses

func (c *Closer) Close()

Close closes the closes and propagates the close to any child, on close the close callback will be called, this can be used for custom cleanup like closing a TCP socket.

func (*Closer) Done Uses

func (c *Closer) Done() <-chan struct{}

Done returns the synchronization channel, the channel will be closed if `Close()` was called on the current node or any parent it may have.

func (*Closer) Err Uses

func (c *Closer) Err() error

Err returns an error if the Closer was already closed.

type CloserFunc Uses

type CloserFunc func()

CloserFunc is the function called by the Closer on `Close()`.

type Config Uses

type Config struct {
    Host           string                  `config:"host"`
    Timeout        time.Duration           `config:"timeout" validate:"nonzero,positive"`
    MaxMessageSize cfgtype.ByteSize        `config:"max_message_size" validate:"nonzero,positive"`
    MaxConnections int                     `config:"max_connections"`
    TLS            *tlscommon.ServerConfig `config:"ssl"`
}

Config exposes the tcp configuration.

func (*Config) Validate Uses

func (c *Config) Validate() error

Validate validates the Config option for the tcp input.

type ConnectionHandler Uses

type ConnectionHandler interface {
    Handle(CloseRef, net.Conn) error
}

ConnectionHandler interface provides mechanisms for handling of incoming TCP connections

type DeadlineReader Uses

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

DeadlineReader allow read to a io.Reader to timeout, the timeout is refreshed on every read.

func NewDeadlineReader Uses

func NewDeadlineReader(c net.Conn, timeout time.Duration) *DeadlineReader

NewDeadlineReader returns a new DeadlineReader

func (*DeadlineReader) Read Uses

func (d *DeadlineReader) Read(p []byte) (n int, err error)

Read reads the number of bytes from the reader

type HandlerFactory Uses

type HandlerFactory func(config Config) ConnectionHandler

HandlerFactory returns a ConnectionHandler func

func SplitHandlerFactory Uses

func SplitHandlerFactory(callback inputsource.NetworkFunc, splitFunc bufio.SplitFunc) HandlerFactory

SplitHandlerFactory allows creation of a ConnectionHandler that can do splitting of messages received on a TCP connection.

type ResetableLimitedReader Uses

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

ResetableLimitedReader is based on LimitedReader but allow to reset the byte read and return a specific error when we reach the limit.

func NewResetableLimitedReader Uses

func NewResetableLimitedReader(reader io.Reader, maxReadBuffer uint64) *ResetableLimitedReader

NewResetableLimitedReader returns a new ResetableLimitedReader

func (*ResetableLimitedReader) Read Uses

func (m *ResetableLimitedReader) Read(p []byte) (n int, err error)

Read reads the specified amount of byte

func (*ResetableLimitedReader) Reset Uses

func (m *ResetableLimitedReader) Reset()

Reset resets the number of byte read

type Server Uses

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

Server represent a TCP server

func New Uses

func New(
    config *Config,
    factory HandlerFactory,
) (*Server, error)

New creates a new tcp server

func (*Server) Start Uses

func (s *Server) Start() error

Start listen to the TCP socket.

func (*Server) Stop Uses

func (s *Server) Stop()

Stop stops accepting new incoming TCP connection and Close any active clients

Package tcp imports 17 packages (graph) and is imported by 34 packages. Updated 2019-11-18. Refresh now. Tools for package owners.