Documentation
¶
Index ¶
Constants ¶
const ( DefaultBrokerAddr = "localhost:9092" DefaultBufferSize = 1024 DefaultNumProducers = 1 DefaultNumWorkers = 2 )
The default option values.
const (
EnvBrokerAddrs = "PCAS_KAFKA_BROKERS"
)
The environment variables consulted
Variables ¶
This section is empty.
Functions ¶
func SplitBrokerString ¶ added in v0.1.45
SplitBrokerString splits S on commas, returning the distinct non-empty trimmed pieces.
Types ¶
type ClientConfig ¶ added in v0.1.45
type ClientConfig struct {
Formatter logger.Formatter // The formatter for the log messages
BrokerAddrs []string // The broker addresses for the Kafka producers
BufferSize int // The size of the message buffer
NumProducers int // The number of Kafka producers
NumWorkers int // The number of workers feeding log messages to the producers
Log log.Interface // The destination log for debugging
}
ClientConfig describes the options that the user can set on a client connection
func DefaultConfig ¶ added in v0.1.45
func DefaultConfig() *ClientConfig
DefaultConfig returns a new client configuration initialised with the default values. The initial default value for the broker addresses will be read from the environment variable PCAS_KAFKA_BROKERS.
func SetDefaultConfig ¶ added in v0.1.45
func SetDefaultConfig(c *ClientConfig) *ClientConfig
SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.
func (*ClientConfig) Copy ¶ added in v0.1.45
func (c *ClientConfig) Copy() *ClientConfig
Copy returns a deep copy of the configuration.
func (*ClientConfig) Validate ¶ added in v0.1.45
func (c *ClientConfig) Validate() error
Validate validates the client configuration, returning an error if there's a problem.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a logger that sends log messages to Kafka.
func New ¶
func New(cfg *ClientConfig) (*Log, error)
New returns a Kafka logger. It is the caller's responsibility to call Close on the returned *Log when finished with it, otherwise resources will leak.