kafka

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EncodingJSON is used for timeseries encoded as Protobuf-based JSON.
	EncodingJSON = "json"
	// EncodingProto is used for timeseries encoded as Protobuf.
	EncodingProto = "protobuf"
)

Variables

View Source
var (
	// AllEncodings is a list of all supported encodings.
	AllEncodings = []string{EncodingJSON, EncodingProto}
)

Functions

This section is empty.

Types

type Factory

type Factory struct {
	producer.Builder
	// contains filtered or unexported fields
}

Factory implements storage.Factory and creates write-only storage components backed by kafka.

func NewFactory

func NewFactory() *Factory

NewFactory creates a new Factory.

func (*Factory) AddFlags

func (f *Factory) AddFlags(flagSet *flag.FlagSet)

AddFlags implements plugin.Configurable

func (*Factory) Close

func (f *Factory) Close() error

Close closes the resources held by the factory

func (*Factory) CreateWriter

func (f *Factory) CreateWriter() (metricstore.Writer, error)

func (*Factory) InitFromOptions

func (f *Factory) InitFromOptions(o Options)

InitFromOptions initializes factory from options.

func (*Factory) InitFromViper

func (f *Factory) InitFromViper(v *viper.Viper)

InitFromViper implements plugin.Configurable

func (*Factory) Initialize

func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error

Initialize implements storage.Factory

type JSONUnmarshaller

type JSONUnmarshaller struct{}

JSONUnmarshaller implements Unmarshaller

func NewJSONUnmarshaller

func NewJSONUnmarshaller() *JSONUnmarshaller

NewJSONUnmarshaller constructs a JSONUnmarshaller

func (*JSONUnmarshaller) Unmarshal

func (J *JSONUnmarshaller) Unmarshal(msg []byte) ([]prompb.TimeSeries, error)

type Marshaller

type Marshaller interface {
	MarshalMetric([]prompb.TimeSeries) ([]byte, error)
}

Marshaller encodes a metric into a byte array to be sent to Kafka

type Options

type Options struct {
	Config   producer.Configuration `mapstructure:",squash"`
	Topic    string                 `mapstructure:"topic"`
	Encoding string                 `mapstructure:"encoding"`
}

Options stores the configuration options for Kafka

func (*Options) AddFlags

func (opt *Options) AddFlags(flagSet *flag.FlagSet)

AddFlags adds flags for Options

func (*Options) InitFromViper

func (opt *Options) InitFromViper(v *viper.Viper)

InitFromViper initializes Options with properties from viper

type ProtobufUnmarshaller

type ProtobufUnmarshaller struct{}

ProtobufUnmarshaller implements Unmarshaller

func NewProtobufUnmarshaller

func NewProtobufUnmarshaller() *ProtobufUnmarshaller

NewProtobufUnmarshaller constructs a ProtobufUnmarshaller

func (*ProtobufUnmarshaller) Unmarshal

func (p *ProtobufUnmarshaller) Unmarshal(msg []byte) ([]prompb.TimeSeries, error)

type Unmarshaller

type Unmarshaller interface {
	Unmarshal([]byte) ([]prompb.TimeSeries, error)
}

type Writer

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

Writer writes metric to kafka. Implements metricstore.Writer

func NewMetricWriter

func NewMetricWriter(
	producer sarama.AsyncProducer,
	marshaller Marshaller,
	topic string,
	factory metrics.Factory,
	logger *zap.Logger,
) *Writer

func (*Writer) Close

func (w *Writer) Close() error

Close closes metricWriter by closing producer

func (*Writer) WriteMetric

func (w *Writer) WriteMetric(ts []prompb.TimeSeries) error

WriteMetric writes the time series to kafka.

type WriterMetrics

type WriterMetrics struct {
	WrittenSuccess metrics.Counter
	WrittenFailure metrics.Counter
}

Jump to

Keyboard shortcuts

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