kafka

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package kafka enables writing metric values to kafka.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFile

func FromFile(filename string) (result pstore.LimitedRecordWriter, err error)

FromFile creates a new writer from a configuration file.

func IsTypeSupported

func IsTypeSupported(t types.Type) bool

IsTypeSupported returns true if kafka supports the given metric type

func LMMJSONPayload

func LMMJSONPayload(
	r *pstore.Record,
	tenantId,
	apiKey string,
	slashesToUnderscores bool) map[string]interface{}

LMMJSONPayload returns record as a JSON struct for lmm.

func LMMSerialiseAsBytes

func LMMSerialiseAsBytes(
	r *pstore.Record,
	tenantId,
	apiKey string,
	slashesToUnderscores bool) ([]byte, error)

LMMSerialiseAsBytes serialises r into an LMM json payload. tenantId and apiKey are the LMM tenantId and API key respectively. The returned payload includes these as LMM expects them.

func LMMSerialiseAsReader

func LMMSerialiseAsReader(
	r *pstore.Record,
	tenantId,
	apiKey string,
	slashesToUnderscores bool) (io.Reader, error)

LMMSerialiseAsReader works like LMMSerialiseAsBytes except that it returns the payload as an io.Reader. The payload itself is 100% buffered within the returned reader.

func NewFakeWriter

func NewFakeWriter() pstore.LimitedRecordWriter

NewFakeWriter creates a new writer that dumps the JSON to stdout. The tenantId and apiKey are fake for security.

func NewFakeWriterToPath

func NewFakeWriterToPath(path string) (pstore.LimitedRecordWriter, error)

NewFakeWriterToPath creates a new writer that dumps the JSON to a file with given path. The tenantId and apiKey are fake for security.

func ToFloat64

func ToFloat64(r *pstore.Record) float64

ToFloat64 converts the metric value in r to a floating point value for kafka.

Types

type Config

type Config struct {
	// The KAFKA endpoints in "hostname:port" format.
	// At least one is required.
	Endpoints []string `yaml:"endpoints"`
	// The KAFKA topic. Required.
	Topic string `yaml:"topic"`
	// The KAFKA clientId. Required.
	ClientId string `yaml:"clientId"`
	// User credential. Required.
	TenantId string `yaml:"tenantId"`
	// User credential. Required.
	ApiKey string `yaml:"apiKey"`
}

Config represents the configuration of kafka. Config implements yamlutil.Config

func (*Config) NewWriter

func (c *Config) NewWriter() (pstore.LimitedRecordWriter, error)

func (*Config) Reset

func (c *Config) Reset()

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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