producer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package producer exposes common logic that all Go collectors can use for producing nerd events

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addresses []string      `json:"addresses"`
	Timeout   time.Duration `json:"timeout"`
	Topic     string        `json:"topic"`
	Type      string        `json:"type"`
}

Config holds the necessary configuration to set up a producer

type KafkaProducer

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

KafkaProducer is a Producer implementation for sending events through a Kafka topic

func NewKafkaProducer

func NewKafkaProducer(conf Config) (*KafkaProducer, error)

NewKafkaProducer checks the provided addresses and creates a Kafka producer

func (*KafkaProducer) Close

func (kp *KafkaProducer) Close()

Close shuts down the underlying Kafka writer

func (*KafkaProducer) Send

func (kp *KafkaProducer) Send(seriesID string, event []byte) error

Send writes the given event to the configured Kafka topic

type Producer

type Producer interface {
	Send(seriesID string, event []byte) error
	Close()
}

Producer is an abstraction over how the service sends metrics updates to nerd

func New

func New(conf Config) (Producer, error)

New returns a producer of the type selected in the configuration

type RestProducer

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

RestProducer is a Producer implementation for sending events directly to nerd through its API. Its use is discouraged when pairing it with a production nerd setup given that it doesn't support load balancing by series ID

func NewRestProducer

func NewRestProducer(conf Config) (*RestProducer, error)

NewRestProducer checks the provided addresses and creates a rest producer

func (*RestProducer) Close

func (rp *RestProducer) Close()

Close is required to be defined to comply with the Producer interface but not really needed for rest

func (*RestProducer) Send

func (rp *RestProducer) Send(seriesID string, event []byte) error

Send posts the given event to one of the defined addresses picked at random

Jump to

Keyboard shortcuts

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