mappers

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 12 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GonxMapper

type GonxMapper[T MapInitialisedRow] struct {
	// contains filtered or unexported fields
}

func NewGonxMapper

func NewGonxMapper[T MapInitialisedRow](formats ...string) *GonxMapper[T]

func (*GonxMapper[T]) Identifier

func (c *GonxMapper[T]) Identifier() string

func (*GonxMapper[T]) Map

func (c *GonxMapper[T]) Map(_ context.Context, a any, opts_ ...MapOption[T]) (T, error)

type GrokMapper added in v0.2.0

type GrokMapper[T MapInitialisedRow] struct {
	// contains filtered or unexported fields
}

func NewGrokMapper added in v0.2.0

func NewGrokMapper[T MapInitialisedRow](layout string, patterns map[string]string) (*GrokMapper[T], error)

NewGrokMapper creates a new GrokMapper which contains a grok parser for each layout. patterns is a map of pattern names to grok patterns.

func (*GrokMapper[T]) GetRegex added in v0.2.0

func (c *GrokMapper[T]) GetRegex() (_ string, err error)

func (*GrokMapper[T]) Identifier added in v0.2.0

func (c *GrokMapper[T]) Identifier() string

func (*GrokMapper[T]) Map added in v0.2.0

func (c *GrokMapper[T]) Map(_ context.Context, a any, opts ...MapOption[T]) (T, error)

type HeaderHandler added in v0.4.0

type HeaderHandler interface {
	OnHeader(header []string)
}

HeaderHandler is an interface which provides a method for handling the header row it should be implemented by any mapper which wishes to be notified of the header row

type MapInitialisedRow added in v0.2.0

type MapInitialisedRow interface {
	InitialiseFromMap(m map[string]string) error
}

MapInitialisedRow is an interface which provides a means to initialise a row struct from a string map this is used in combination with the GonxMapper/GrokMapper

type MapOption added in v0.2.0

type MapOption[R any] func(Mapper[R])

func WithHeader added in v0.4.0

func WithHeader[R any](header []string) MapOption[R]

WithHeader is a MapOption that allows you to set the header for the mapper

type Mapper added in v0.2.0

type Mapper[R any] interface {
	Identifier() string
	// Map converts raw rows to the desired format (type 'R')
	Map(context.Context, any, ...MapOption[R]) (R, error)
}

Mapper is a generic interface which provides a method for mapping raw source data into row structs R is the type of the row struct which the mapperFunc outputs

type RegexMapper added in v0.2.0

type RegexMapper[T MapInitialisedRow] struct {
	// contains filtered or unexported fields
}

func NewRegexMapper added in v0.2.0

func NewRegexMapper[T MapInitialisedRow](pattern string) (*RegexMapper[T], error)

NewRegexMapper creates a new RegexMapper with the provided pattern.

func (*RegexMapper[T]) Identifier added in v0.2.0

func (c *RegexMapper[T]) Identifier() string

func (*RegexMapper[T]) Map added in v0.2.0

func (c *RegexMapper[T]) Map(_ context.Context, a any, opts ...MapOption[T]) (T, error)

Jump to

Keyboard shortcuts

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