utils

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorTooLarge = errors.New("too large")

Functions

func DuplicateMap

func DuplicateMap(m map[string]interface{}) map[string]interface{}

func IsInterfaceNil

func IsInterfaceNil(v interface{}) bool

func ParseCLI

func ParseCLI(prefix string, args []string, out interface{}) error

Parses a list of tokens (like from a CLI) into a struct, using json.Unmarshal. Simplifies the population of configuration structs via CLI of a container without a custom container.

func Pipeliner

The Pipeliner will consume elements from `it()` and process them with `proc()` in parallel (`nParallel` at a time). The returned generator will receive the processed elements _in the order they were generated_. The closer terminates all the pipeline (blocking). If the `it()` returns a `nil` element, it signifies the termination of the pipeline and the generator will produce a `nil` element.

func StandardInt

func StandardInt(v interface{}) (uint64, bool)

func UnmarshalCleanJSON

func UnmarshalCleanJSON(data string) (map[string]interface{}, error)

Types

type BoolExtractor

type BoolExtractor func(evt Dict) []bool

Generator for closures getting a bool at a specific path within a JSON object, if present.

func MakeExpandableExtractorForBool added in v1.19.7

func MakeExpandableExtractorForBool(path string, isAutoExpand bool) BoolExtractor

func MakeExtractorForBool

func MakeExtractorForBool(path string) BoolExtractor

type Dict

type Dict map[string]interface{}

func (Dict) Duplicate

func (d Dict) Duplicate() Dict

func (Dict) ExpandableFindOneString added in v1.19.7

func (d Dict) ExpandableFindOneString(path string) string

func (Dict) ExpandableFindString added in v1.19.7

func (d Dict) ExpandableFindString(path string) []string

func (Dict) FindBool

func (d Dict) FindBool(path string) []bool

func (Dict) FindDict

func (d Dict) FindDict(path string) []Dict

func (Dict) FindInt

func (d Dict) FindInt(path string) []uint64

func (Dict) FindList

func (d Dict) FindList(path string) []List

func (Dict) FindOneBool

func (d Dict) FindOneBool(path string) bool

func (Dict) FindOneDict

func (d Dict) FindOneDict(path string) Dict

func (Dict) FindOneInt

func (d Dict) FindOneInt(path string) uint64

func (Dict) FindOneList

func (d Dict) FindOneList(path string) List

func (Dict) FindOneOpaque

func (d Dict) FindOneOpaque(path string) interface{}

func (Dict) FindOneString

func (d Dict) FindOneString(path string) string

func (Dict) FindOpaque

func (d Dict) FindOpaque(path string) []interface{}

func (Dict) FindString

func (d Dict) FindString(path string) []string

func (Dict) GetBool

func (d Dict) GetBool(k string) (bool, bool)

func (Dict) GetBuffer

func (d Dict) GetBuffer(k string) ([]byte, bool)

func (Dict) GetDict

func (d Dict) GetDict(k string) (Dict, bool)

func (Dict) GetInt

func (d Dict) GetInt(k string) (uint64, bool)

func (Dict) GetList

func (d Dict) GetList(k string) (List, bool)

func (Dict) GetListOfDict

func (d Dict) GetListOfDict(k string) ([]Dict, bool)

func (Dict) GetListOfString

func (d Dict) GetListOfString(k string) ([]string, bool)

func (Dict) GetString

func (d Dict) GetString(k string) (string, bool)

func (Dict) ImportFromStruct

func (d Dict) ImportFromStruct(in interface{}) (Dict, error)

func (Dict) Keys

func (d Dict) Keys() []string

func (Dict) UnMarshalToStruct

func (d Dict) UnMarshalToStruct(out interface{}) error

func (*Dict) UnmarshalJSON

func (d *Dict) UnmarshalJSON(data []byte) error

func (Dict) Values

func (d Dict) Values() []interface{}

type DictExtractor

type DictExtractor func(evt Dict) []Dict

Generator for closures getting a Dict at a specific path within a JSON object, if present.

func MakeExpandableExtractorForDict added in v1.19.7

func MakeExpandableExtractorForDict(path string, isAutoExpand bool) DictExtractor

func MakeExtractorForDict

func MakeExtractorForDict(path string) DictExtractor

type Element

type Element = interface{}

type Event

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

func NewEvent

func NewEvent() *Event

func (*Event) Clear

func (e *Event) Clear()

func (*Event) IsSet

func (e *Event) IsSet() bool

func (*Event) Set

func (e *Event) Set()

func (*Event) Wait

func (e *Event) Wait()

func (*Event) WaitFor

func (e *Event) WaitFor(d time.Duration) bool

type IntExtractor

type IntExtractor func(evt Dict) []uint64

Generator for closures getting an int at a specific path within a JSON object, if present.

func MakeExpandableExtractorForInt added in v1.19.7

func MakeExpandableExtractorForInt(path string, isAutoExpand bool) IntExtractor

func MakeExtractorForInt

func MakeExtractorForInt(path string) IntExtractor

type List

type List []interface{}

type ListExtractor

type ListExtractor func(evt Dict) []List

Generator for closures getting a Dict at a specific path within a JSON object, if present.

func MakeExpandableExtractorForList added in v1.19.7

func MakeExpandableExtractorForList(path string, isAutoExpand bool) ListExtractor

func MakeExtractorForList

func MakeExtractorForList(path string) ListExtractor

type OpaqueExtractor

type OpaqueExtractor func(evt Dict) []interface{}

Generator for closures getting an element at a specific path within a JSON object, if present.

func MakeExpandableExtractorForOpaque added in v1.19.7

func MakeExpandableExtractorForOpaque(path string, isAutoExpand bool) OpaqueExtractor

func MakeExtractorForOpaque

func MakeExtractorForOpaque(path string) OpaqueExtractor

type PipelinerClose

type PipelinerClose = func()

type PipelinerGenerator

type PipelinerGenerator = func() (Element, error)

type PipelinerMapper

type PipelinerMapper = func(Element) Element

type PresenceExtractor

type PresenceExtractor func(evt Dict) bool

func MakeExtractorForPresence

func MakeExtractorForPresence(path string) PresenceExtractor

type StreamTokenizer

type StreamTokenizer struct {
	MaxSize      int
	ExpectedSize int
	Token        byte
	// contains filtered or unexported fields
}

func (*StreamTokenizer) Add

func (t *StreamTokenizer) Add(data []byte) ([][]byte, error)

type StringExtractor

type StringExtractor func(evt Dict) []string

Generator for closures getting a string at a specific path within a JSON object, if present.

func MakeExpandableExtractorForString added in v1.19.7

func MakeExpandableExtractorForString(path string, isAutoExpand bool) StringExtractor

func MakeExtractorForString

func MakeExtractorForString(path string) StringExtractor

Jump to

Keyboard shortcuts

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