eventParser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParsingQueueDepth    = "parsing_queue_depth"
	DroppedEventsCounter = "dropped_events_count"
)

Variables

This section is empty.

Functions

func NewEventsEndpoint

func NewEventsEndpoint(p *EventParser) endpoint.Endpoint

NewEventsEndpoint returns the endpoint for /events handler.

func NewEventsEndpointDecode

func NewEventsEndpointDecode() kithttp.DecodeRequestFunc

NewEventsEndpointDecode returns DecodeRequestFunc wrapper from the /events endpoint.

func NewEventsEndpointEncode

func NewEventsEndpointEncode() kithttp.EncodeResponseFunc

NewEventsEndpointEncode returns EncodeResponseFunc wrapper from the /events endpoint.

func ProvideMetrics

func ProvideMetrics() fx.Option

ProvideMetrics is the metrics provider for eventParser

Types

type EventParser

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

func NewEventParser

func NewEventParser(sender EventSenderFunc, logger *log.Logger, o ParserConfig, measures Measures) (*EventParser, error)

NewEventParser validates and constructs an EventParser from provided the configs.

func Provide

func Provide(in ParserIn, opt ParserConfig) (*EventParser, error)

Provide is an uber/fx style provider for this package's components

func (*EventParser) Start

func (p *EventParser) Start() func(context.Context) error

Start creates the parser queue and begins a new goroutine to pull messages from and parse the deviceID from the event.

func (*EventParser) Stop

func (p *EventParser) Stop() func(context.Context) error

Stop closes the parser queue and waits for all remaining goroutines to finish.

type EventSenderFunc

type EventSenderFunc func(deviceID string, event *wrp.Message)

EventSenderFunc is the function type used pass events to manager.

type Measures

type Measures struct {
	fx.In
	EventParsingQueue         metrics.Gauge   `name:"parsing_queue_depth"`
	DroppedEventsParsingCount metrics.Counter `name:"dropped_events_count"`
}

Measures describes the defined metrics that will be used by eventparser

func NewMeasures

func NewMeasures(p provider.Provider) *Measures

NewMeasures returns desired metrics

type ParserConfig

type ParserConfig struct {
	QueueSize  int
	MaxWorkers int
	RegexRules []rules.RuleConfig
}

ParserConfig is the config provided to create a new EventParser.

type ParserIn added in v0.2.0

type ParserIn struct {
	fx.In

	Lifecycle   fx.Lifecycle
	EventSender EventSenderFunc
	Logger      log.Logger
	Measures    Measures
}

ParserIn sets all the dependencies for this package's components

type Response

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

Jump to

Keyboard shortcuts

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