plugin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigStore

type ConfigStore interface {
	Bool(name string) (bool, bool)
	Duration(name string) (time.Duration, bool)
	Int(name string) (int, bool)
	String(name string) (string, bool)
	Strings(name string) ([]string, bool)
}

ConfigStore defines an interface to the plugin configuration.

type FLBConfigStore

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

FLBConfigStore provides access to the fluent-bit configuration for the plugin.

func NewFLBConfigStore

func NewFLBConfigStore(ctx unsafe.Pointer, l *zerolog.Logger) FLBConfigStore

func (*FLBConfigStore) Bool

func (f *FLBConfigStore) Bool(name string) (bool, bool)

Bool retrieves a boolean from the plugin configuration.

The value and if the value was found are returned.

func (*FLBConfigStore) Duration

func (f *FLBConfigStore) Duration(name string) (time.Duration, bool)

Duration retrieves a time.Duration from the plugin configuration.

The value and if the value was found are returned.

func (*FLBConfigStore) Int

func (f *FLBConfigStore) Int(name string) (int, bool)

Int retrieves an integer from the plugin configuration.

The value and if the value was found are returned.

func (*FLBConfigStore) String

func (f *FLBConfigStore) String(name string) (string, bool)

String retrieves a string from the plugin configuration.

The value and if the value was found are returned.

func (*FLBConfigStore) Strings

func (f *FLBConfigStore) Strings(name string) ([]string, bool)

Strings retrieves a list of strings from the plugin configuration.

These should be comma seperated in the configuration file. The value and if the value was found are returned.

type FLBRecordReader

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

An FLBRecordReader decodes a MsgPack record from fluent-bit

func NewFLBRecordReader

func NewFLBRecordReader() (*FLBRecordReader, error)

NewFLBRecordReader creates a new FLBRecordReader, and initializes the MsgPack handler and decoder.

func (*FLBRecordReader) ReadRecord

func (r *FLBRecordReader) ReadRecord() (time.Time, map[string]interface{}, error)

ReadRecord reads the next record from bytes provided by fluent-bit.

These records are encoded as [ts, record] slices. ReadRecord converts these to time.Time and map[string]interface{} for ready encoding as JSON and/or PubSub attributes.

func (*FLBRecordReader) ResetReader

func (r *FLBRecordReader) ResetReader(data unsafe.Pointer, length int)

ResetReader resets the MsgPack decoder contained in the FLBRecordReader, readying it to decode another record.

type FLBTime

type FLBTime struct {
	time.Time
}

func (FLBTime) ReadExt

func (t FLBTime) ReadExt(i interface{}, b []byte)

ReadExt handles decoding the MsgPack extension

func (FLBTime) WriteExt

func (t FLBTime) WriteExt(interface{}) []byte

type OutputPlugin

type OutputPlugin struct {
	// Unique ID of the plugin instance
	ID int
	// Field to create/update in the record with the fluent-bit timestamp
	TSField string
	// A list of record fields to set as [cloud.google.com/go/pubsub.Message] attributes
	As []string
	// If fields from As should be kept in the record, as well as made attributes.
	KA bool
	// Debug flag
	D bool
	// FluentBit record reader
	R *FLBRecordReader
	// PubSub Topic
	*pubsub.Topic
}

OutputPlugin is a fluent-bit output plugin for Google Cloud PubSub.

func NewPluginFromConfig

func NewPluginFromConfig(ctx context.Context, config *OutputPluginConfig, opts ...option.ClientOption) (*OutputPlugin, error)

NewPluginFromConfig creates a new OutputPlugin from an OutputPluginConfig.

Optionally taking some additional options for the RPC client.

func (*OutputPlugin) CreateMessage

func (p *OutputPlugin) CreateMessage(ts time.Time, tag string, record map[string]interface{}) (*pubsub.Message, error)

CreateMessage creates a pubsub.Message from the timestamp, tag, and record from fluent-bit.

type OutputPluginConfig

type OutputPluginConfig struct {
	ID      int                    // Plugin ID.
	PID     string                 // Google Cloud project id.
	TID     string                 // PubSub topic ID.
	Crds    string                 // Google Cloud credentials file.
	TSField string                 // Field to populate/update with fluent-bit timestamp.
	As      []string               // List of record fields to use as PubSub.Message attributes
	KA      bool                   // If record fields used as attributes should be kept in the record.
	PS      pubsub.PublishSettings // Pubsub PublishSettings
	D       bool                   // Debug flag
}

OutputPluginConfig represents the configuration used to create an OutputPlugin

func BuildPluginConfig

func BuildPluginConfig(id int, cs ConfigStore) *OutputPluginConfig

BuildPluginConfig creates the OutputPluginConfig from a ConfigStore

func (*OutputPluginConfig) Validate

func (c *OutputPluginConfig) Validate() error

Validate validates that all required fields are present in the OutputPluginConfig.

Jump to

Keyboard shortcuts

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