inputsocket

package
v0.0.0-...-c13075e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 13 Imported by: 3

README

socket input

Input event message should end with new line (\n) unless UDP packet mode is used.

Synopsis

{
	"input": [
		{
			"type": "socket",

			// Socket type. Must be one of ["tcp", "udp", "unix", "unixpacket"].
			"socket": "tcp",

			// For TCP or UDP, address must have the form `host:port`.
			// For Unix networks, the address must be a file system path.
			"address": "localhost:9999",

			// (optional) SO_REUSEPORT applied or not, default: false
			"reuseport": false

			// (optional) sets UDP into packet mode, so each packet is processed individually.
			// In this mode the field "host_ip" is added with the source of the IP address in the format "host:port"
			"packetmode": true

			// (optional) set packet buffer size, for UDP this must be larger than the biggest packet you will receive.
			// Packets larger than this will be truncated down to the buffer size.
			"buffersize": 5000

			// (optional) codec that will process the incoming message. By default it will be processed as JSON,
			// if you want a different codec or the default (does nothing) you can configure this here.
			"codec": "default"
		}
	]
}

Note: at the moment, UNIXGRAM socket are not supported.

Documentation

Index

Constants

View Source
const ErrorTag = "gogstash_input_socket_error"

ErrorTag tag added to event when process module failed

View Source
const ModuleName = "socket"

ModuleName is the name used in config file

Variables

View Source
var (
	ErrorUnknownSocketType1 = errutil.NewFactory("%q is not a valid socket type")
	ErrorSocketAccept       = errutil.NewFactory("socket accept error")
)

errors

Functions

func InitHandler

func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeInputConfig, error)

InitHandler initialize the input plugin

Types

type InputConfig

type InputConfig struct {
	config.InputConfig
	Socket string `json:"socket"` // Type of socket, must be one of ["tcp", "udp", "unix", "unixpacket"].
	// For TCP or UDP, address must have the form `host:port`.
	// For Unix networks, the address must be a file system path.
	Address    string `json:"address"`
	ReusePort  bool   `json:"reuseport"`
	BufferSize int    `json:"buffer_size" yaml:"buffer_size"`
	// packetmode is only valid for UDP sessions and handles each packet as a message on its own
	PacketMode bool `json:"packetmode"`
}

InputConfig holds the configuration json fields and internal objects

func DefaultInputConfig

func DefaultInputConfig() InputConfig

DefaultInputConfig returns an InputConfig struct with default values

func (*InputConfig) Start

func (i *InputConfig) Start(ctx context.Context, msgChan chan<- logevent.LogEvent) error

Start wraps the actual function starting the plugin

Jump to

Keyboard shortcuts

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