router

package
v6.27.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router interface {
	Route(map[string]interface{}) map[string]interface{}
}

Router is an an interface for an object that can route log lines.

func NewFromConfig

func NewFromConfig(filename string) (Router, error)

NewFromConfig constructs a Router using the configuration specified as yaml in `filename`. The routing rules should be placed under the "routes" key on the root-level map in the file. Validation is performed as described in parse.go.

func NewFromConfigBytes

func NewFromConfigBytes(fileBytes []byte) (Router, error)

NewFromConfigBytes constructs a Router using the configuration specified as bytes typically read from a binary file. This allows us to package kv routing yaml files into binaries like gearcmd. The routing rules should be placed under the "routes" key on the root-level map in the file. Validation is performed as described in parse.go.

func NewFromRoutes

func NewFromRoutes(routes map[string]Rule) (Router, error)

NewFromRoutes constructs a RuleRouter using the provided map of route names to Rules.

type Rule

type Rule struct {
	Name     string       `json:"-"`
	Matchers RuleMatchers `json:"matchers"`
	Output   RuleOutput   `json:"output"`
}

Rule is a log routing rule

func (*Rule) Matches

func (r *Rule) Matches(msg map[string]interface{}) bool

Matches returns true if the `msg` matches the matchers specified in this routing rule.

func (*Rule) OutputFor

func (r *Rule) OutputFor(msg map[string]interface{}) map[string]interface{}

OutputFor returns the output map for this routing rule with substitutions applied in accordance with the current environment and the contents of the message.

type RuleMatchers

type RuleMatchers map[string][]string

RuleMatchers describes which log lines a router rule applies to.

func (*RuleMatchers) UnmarshalYAML

func (m *RuleMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the `matchers` section of a log-routing configuration and validates it.

type RuleOutput

type RuleOutput map[string]interface{}

RuleOutput describes what to do if a log line matches a rule.

type RuleRouter

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

RuleRouter is an object that can route log lines according to `rules`.

func (*RuleRouter) Route

func (r *RuleRouter) Route(msg map[string]interface{}) map[string]interface{}

Route returns routing metadata for the log line `msg`. The outputs (with variable substitutions performed) for each rule matched are placed under the "routes" key.

Jump to

Keyboard shortcuts

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