_example

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct{}

Config is the structure that defines your configuration. It should specify JSON tags for easy serialization & deserialization.

func NewConfig

func NewConfig(c interface{}) (*Config, error)

NewConfig will return the custom Config object. The helper `pkgconfig.NewConfig` does the hard work of converting the input from:

  • yaml
  • json
  • Config{}
  • &Config{}

into a *Config{} object.

func (*Config) FromJSON

func (c *Config) FromJSON(in string) error

FromJSON will consume JSON and will set the values of the structure to the values provided in the input string.

func (*Config) FromYAML

func (c *Config) FromYAML(in string) error

FromYAML will consume YAML and will set the values of the structure to the values provided in the input string.

func (*Config) JSON

func (c *Config) JSON() (string, error)

JSON exports the config as JSON

func (*Config) String

func (c *Config) String() string

String turns the config into a readable string

func (*Config) Validate

func (c *Config) Validate() error

Validate will return validation errors if the configuration has invalid values. NOTE: Make sure to run `WithDefaults()` prior to validation as `nil` (not supplied) values usually are not valid configuration values.

func (Config) WithDefaults

func (c Config) WithDefaults() *Config

WithDefaults constructs a new Config object and will set any values for any values that are missing. A common practice is to have the member variables of a struct to always be pointers (e.g: *int) so that they can be `nil`, which indicates "not supplied." It would be these `nil` values that will get filled in.

func (*Config) YAML

func (c *Config) YAML() (string, error)

YAML exports the config as YAML.

type Filter

type Filter struct{}

Filter is the structure that will implement the `Filter()` interface

func NewFilter

func NewFilter(config interface{}) (*Filter, error)

NewFilter takes in a configuration and will create a new `Filter` structure based upon the configuration. NewFilter should validate the configuration and return any config validation errors. `NewConfig` should wrap its returned error in an `InvalidConfigErr` struct, so wrapping it again is not necessary.

func (*Filter) Config added in v0.4.0

func (f *Filter) Config() interface{}

func (*Filter) Filter

func (f *Filter) Filter(evt event.Event) []event.Event

Filter the event based on the configuration information. This example passes the event on as-is.

func (*Filter) Name added in v0.4.0

func (f *Filter) Name() string

func (*Filter) Plugin added in v0.4.0

func (f *Filter) Plugin() string

func (*Filter) Tenant added in v0.4.0

func (f *Filter) Tenant() tenant.Id

Jump to

Keyboard shortcuts

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