inputlorem

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: 10 Imported by: 0

README

gogstash input lorem

Synopsis

input:
  # type Must be "lorem"
  - type: "lorem"

    # worker count to generate lorem, default: 1
    worker: 1

    # duration to generate lorem, set 0 to generate forever, default: 30s
    duration: "30s"

    # (optional) message format in go text/template
    # support functions:
    #   `TimeFormat(layout string) string`
    #   `Word(min, max int) string`
    #   `Sentence(min, max int) string`
    #   `Paragraph(min, max int) string`
    #   `Email() string`
    #   `Host() string`
    #   `Url() string`
    # eg. '{{.TimeFormat "20060102-150405.000"}}|ERROR|{{.Sentence 1 5}}' =>
    #   '20180921-173749.186|ERROR|Valetudinis tria cura cognitionis.'
    format: '{{.Sentence 1 5}}'

    # (optional) send empty messages without any lorem text, default: false
    empty: false

    # (optional) event extra fields, default: nil
    #fields:

Documentation

Index

Constants

View Source
const ModuleName = "lorem"

ModuleName is the name used in config file

Variables

View Source
var (
	ErrNoMessageFormat = errors.New("no message format for lorem input")
)

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
	Worker   int    `json:"worker,omitempty"`   // worker count to generate lorem, default: 1
	Duration string `json:"duration,omitempty"` // duration to generate lorem, set 0 to generate forever, default: 30s

	// format event message using go text/template, default: {{.Sentence 1 5}}
	// support functions:
	//   `TimeFormat(layout string) string`
	//   `Word(min, max int) string`
	//   `Sentence(min, max int) string`
	//   `Paragraph(min, max int) string`
	//   `Email() string`
	//   `Host() string`
	//   `Url() string`
	Format string         `json:"format,omitempty"`
	Fields map[string]any `json:"fields,omitempty"` // event extra fields
	Empty  bool           `json:"empty,omitempty"`  // send empty messages without any lorem text, default: false
	// contains filtered or unexported fields
}

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 (t *InputConfig) Start(ctx context.Context, msgChan chan<- logevent.LogEvent) (err 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