common

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProducerMessagePool = sync.Pool{
	New: func() interface{} {
		return &sarama.ProducerMessage{}
	},
}

Functions

func GetSaramaProducer

func GetSaramaProducer(topic string, partition int32, value []byte) *sarama.ProducerMessage

Types

type Config

type Config struct {
	// Common
	Name                  string `json:"Name"`
	Type                  Transport
	Compression           string `json:"Compression"`
	DistributionAlgorithm distribution.Algorithm
	Encoding              OutputEncoding
	FlushFrequency        time.Duration `json:"FlushFrequency"`
	ChannelBufferSize     int           `json:"ChannelBufferSize"`
	TLS                   TLSConfig     `json:"TLS"`
	Buffered              bool          `json:"Buffered"`
	// Kafka Transport
	Brokers      []string            `json:"Brokers"`
	RequiredAcks sarama.RequiredAcks `json:"RequiredAcks"`
	RetryMax     int                 `json:"RetryMax"`
	Topic        string              `json:"Topic"`
	Shards       int                 `json:"Shards"`
	Partition    int32               `json:"Partition"`
	//	OrganisationID    int
	// TCP Transport
	Servers          []string
	CompressionLevel int `json:"CompressionLevel"`
}

TODO: Find out reason why Viper ignores custom unmarshal functions and remove workaround from below

func (*Config) FromParsed

func (c *Config) FromParsed(cfg ConfigForFile) error

type ConfigForFile

type ConfigForFile struct {
	// Common
	Name                  string        `json:"Name"`
	Type                  string        `json:"Type"`
	Compression           string        `json:"Compression"`
	DistributionAlgorithm string        `json:"DistributionAlgorithm"`
	Encoding              string        `json:"Encoding"`
	FlushFrequency        time.Duration `json:"FlushFrequency"`
	ChannelBufferSize     int           `json:"ChannelBufferSize"`
	TLS                   TLSConfig     `json:"TLS"`
	Buffered              bool          `json:"Buffered"`
	// Kafka Transport
	Brokers      []string            `json:"Brokers"`
	RequiredAcks sarama.RequiredAcks `json:"RequiredAcks"`
	RetryMax     int                 `json:"RetryMax"`
	Topic        string              `json:"Topic"`
	Shards       int                 `json:"Shards"`
	Partition    int32               `json:"Partition"`
	//	OrganisationID    int
	// TCP Transport
	Servers          []string
	CompressionLevel int `json:"CompressionLevel"`
}

type OutputEncoding

type OutputEncoding int
const (
	GraphiteLineEncoding OutputEncoding = iota
	ProtobufEncoding
	JsonEncoding
)

func (*OutputEncoding) FromString

func (e *OutputEncoding) FromString(s string) error

func (*OutputEncoding) MarshalJSON

func (e *OutputEncoding) MarshalJSON() ([]byte, error)

func (OutputEncoding) String

func (e OutputEncoding) String() string

func (*OutputEncoding) UnmarshalJSON

func (e *OutputEncoding) UnmarshalJSON(data []byte) error

func (*OutputEncoding) UnmarshalYAML

func (e *OutputEncoding) UnmarshalYAML(unmarshal func(interface{}) error) error

type TLSConfig

type TLSConfig struct {
	Enabled           bool `json:"Enabled"`
	SkipInsecureCerts bool `json:"SkipInsecureCerts"`
}

type Transport

type Transport int
const (
	TCP Transport = iota
	UDP
	Kafka
)

func (*Transport) FromString

func (e *Transport) FromString(s string) error

func (*Transport) MarshalJSON

func (e *Transport) MarshalJSON() ([]byte, error)

func (Transport) String

func (e Transport) String() string

func (*Transport) UnmarshalJSON

func (e *Transport) UnmarshalJSON(data []byte) error

func (*Transport) UnmarshalYAML

func (e *Transport) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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