Giter VIP home page Giter VIP logo

kafka-consumer-go's Introduction

Go Kafka Consumer

This is a module that provides Kafka consumer and retry logic for services. It registers a new consumer on a configurable list of topics and handles the retrying of messsages using a topic chain.

Installation

It can be installed into a concrete consumer service using:

go get github.com/inviqa/kafka-consumer-go

Documentation

See the docs on how to use this Go module.

Changelog

This project maintains a changelog, which you can find here.

Upgrading

To check upgrade paths between versions, you can use the upgrade doc.

Running tests

This module ships with unit tests. You can run these with go test ./....

Performing a release

See the releasing docs for info.

License

Copyright 2021, Inviqa

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.

kafka-consumer-go's People

Contributors

andytson-inviqa avatar bertalan-kis avatar dantleech avatar jameshalsall avatar kierenevans avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

bertalan-kis

kafka-consumer-go's Issues

Remove env vars used for configuration and inject as part of NewConfig()

Currently, KAFKA_SOURCE_TOPICS and KAFKA_RETRY_INTERVALS env vars, amongst some others, control how this module behaves. The problem with this is that all topics provided as a comma-separated string, and the implementing application needs to provide a HandlerMap where each key is the topic name that is being consumed.

This means that applications either need to hard-code their topic names in their HandlerMap, or duplicate topic names into their own environment variables to manage them externally.

If we removed the KAFKA_* env vars as a way of configuring this module, then we could update config.NewConfig() to accept these options instead, and then the implementing application can decide how to manage this configuration externally.

Allow requests to be routed to handlers based on a descriminator

Currently you can only assign handlers to topics, but it seems common in Kafka to have many message types in a single topic, this leads to each Handler having to know about several message types and needing to delegate conditionally.

We could possibly introduce the possiblity be more opinonated and assign Handlers based on topic AND type.

Add full integration test suite

Currently, we rely on unit testing to prove that this module works, but that is not enough. We should have a full integration test suite that simulates the use of this module to consume messages from a Kafka broker.

Reduce the set up code for implementing services

The effort to use this module in the implementing service is quite large, as demonstrated in https://github.com/inviqa/kafka-consumer-go/blob/master/tools/docs/implementing-a-handler.md.

It would be nicer to simplify the setup, importantly we should wrap up the creation of the producer and consumer collection together.

If we can find any other simplifications then we should make those, and not worry about breaking the API right now as we have not tagged anything up.

Provide ability to use a DB storage mechanism for retry and deadletter messages

Currently, when we store messages for retry, they are sent back to Kafka and stored in a retry topic. Dead-lettered messages are also stored in a topic.

This limits us in terms of how long we can delay consumption of messages, and it's also not an exact science in terms of how long a message is delayed for before it gets retried, because we only sleep in the consumer between consume calls and therefore it can be far longer for messages to be retried than originally intended.

We should add the option of using a DB for retries and dead-lettered messages, with a separate goroutine running if this option is enabled (instead of the retry/dead-letter topic consumer).

Eventually, this should become the only way of handling retries as it is far more precise and cheaper.

Tasks:

  • Add database storage retry mechanism (done in #16)
  • Add job runners to allow apps to easily run maintenance cleanup on the retry table (see #18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.