kafka

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

depo-kafka - Factory wrappers for Shopify/sarama

codecov Build Status GoDoc

Overview

This project contains wrappers for Shopify/sarama that make it easier to integrate with projects using our application framework stackopsd/app or other systems built on our dependency orchestration library stackopsd/depo.

How To Use

This project includes three factories:

  • ConsumgerGroupFactory
  • SyncProducerFactory
  • AsyncProducerFactory

that each create their respectively named sarama components. All factories require a *tls.Config but this value may be set to nil so long as TLS is disabled via configuration. We recommend using stackopsd/depo-tls for satisfying this dependency.

reg := app.NewRegistry()
req.Add(app.TypeDriver, new(kafka.SyncProducerFactory))
req.Add(app.TypeDriver, new(kafka.AsyncProducerFactory))
req.Add(app.TypeDriver, new(kafka.ConsumerGroupFactory))
req.Add(app.TypeDriver, new(tls.Factory)) // depo-tls integration

Developing

Make targets

This project includes a Makefile that makes it easier to develop on the project. The following are the included targets:

  • fmt

    Format all Go code using goimports.

  • generate

    Regenerate any generated code. See gen.go for code generation commands.

  • lint

    Run golangci-lint using the included linter configurations.

  • test

    Run all unit tests for the project and generate a coverage report.

  • integration

    Run all integration tests for the project and generate a coverage report.

  • coverage

    Generate a combined coverage report from the test and integration target outputs.

  • update

    Update all project dependencies to their latest versions.

  • tools

    Generate a local bin/ directory that contains all of the tools used to lint, test, and format, etc.

  • updatetools

    Update all project ools to their latest versions.

  • vendor

    Generate a vendor directory.

  • clean/cleancoverage/cleantools/cleanvendor

    Remove files created by the Makefile. This does not affect any code changes you may have made.

License

Copyright 2019 Kevin Conway

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncProducerConfig

type AsyncProducerConfig struct {
	SharedConfig
	Partitioner      *string        `description:"One of random, hashing, roundrobin, manual."`
	Compression      *string        `description:"One of gzip, lz4, none."`
	CompressionLevel *int           `description:"Compression specific level setting."`
	RequiredAcks     *string        `description:"One of none, local, all."`
	AckTimeout       *time.Duration `description:"Max time to wait for RequiredAcks."`
	MaxMessageBytes  *int           `description:"Max size of a message in bytes."`
	ReturnSuccesses  *bool          `description:"Enable the success channel."`
	ReturnErrors     *bool          `description:"Enable the error channel."`
}

AsyncProducerConfig contains settings for a sarama.AsyncProducer

type AsyncProducerFactory

type AsyncProducerFactory struct {
	TLS *tls.Config
}

AsyncProducerFactory creates sarama.AsyncProducers.

func (*AsyncProducerFactory) Config

Config generates the default configuration.

func (*AsyncProducerFactory) Make

Make produces a sarama.AsyncProducer.

type ConsumerGroupConfig

type ConsumerGroupConfig struct {
	SharedConfig
	SessionTimeout    *time.Duration
	HeartbeatInterval *time.Duration
	RebalanceStrategy *string
	RebalanceTimeout  *time.Duration
	ReturnErrors      *bool
	GroupName         string
}

ConsumerGroupConfig contains settings for a sarama.ConsumerGroup

type ConsumerGroupFactory

type ConsumerGroupFactory struct {
	TLS *tls.Config
}

ConsumerGroupFactory creates sarama.ConsumerGroup.

func (*ConsumerGroupFactory) Config

Config generates the default configuration.

func (*ConsumerGroupFactory) Make

Make produces a sarama.ConsumerGroup.

type NetConfig

type NetConfig struct {
	MaxOpenRequests *int           `description:"Number of requests before blocking happens."`
	DialTimeout     *time.Duration `description:"How long to wait for the initial connection."`
	ReadTimeout     *time.Duration `description:"How long to wait for a response."`
	WriteTimeout    *time.Duration `description:"How long to wait for a transmit."`
	KeepAlive       *time.Duration `description:"How long to allow for idle."`
	TLSEnabled      *bool
}

NetConfig contains settings for the underlying network connections.

type SharedConfig

type SharedConfig struct {
	Net               *NetConfig
	ClientID          *string
	ChannelBufferSize *int
	Version           *string
	Addresses         []string
}

SharedConfig contains the settings used by all Sarama components.

type SyncProducerConfig

type SyncProducerConfig struct {
	SharedConfig
	Partitioner      *string        `description:"One of random, hashing, roundrobin, manual."`
	Compression      *string        `description:"One of gzip, lz4, none."`
	CompressionLevel *int           `description:"Compression specific level setting."`
	RequiredAcks     *string        `description:"One of none, local, all."`
	AckTimeout       *time.Duration `description:"Max time to wait for RequiredAcks."`
	MaxMessageBytes  *int           `description:"Max size of a message in bytes."`
}

SyncProducerConfig contains settings for a sarama.SyncProducer

type SyncProducerFactory

type SyncProducerFactory struct {
	TLS *tls.Config
}

SyncProducerFactory creates sarama.SyncProducers.

func (*SyncProducerFactory) Config

Config generates the default configuration.

func (*SyncProducerFactory) Make

Make produces a sarama.SyncProducer.

Jump to

Keyboard shortcuts

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