Giter VIP home page Giter VIP logo

Comments (10)

liukgg avatar liukgg commented on May 18, 2024

Do you know how do kafka-clients of other language such as Java, Python implement this function?

from ruby-kafka.

dasch avatar dasch commented on May 18, 2024

The Java client has a background thread, I believe. However, I'd like to make the Ruby version more composable.

from ruby-kafka.

mensfeld avatar mensfeld commented on May 18, 2024

@dasch you can take a look into celluloid - it might help you out to provide an abstraction layer for that

from ruby-kafka.

dasch avatar dasch commented on May 18, 2024

@mensfeld I'd like to avoid adding heavy dependencies (such as Celluloid) to this library. I think I'm going to punt on this for a while.

from ruby-kafka.

mensfeld avatar mensfeld commented on May 18, 2024

@dasch you could also do what newrelic is doing for their monitoring stuff - they spin up a thread and push stuff there that gets flushed to their servers from time to time

from ruby-kafka.

dasch avatar dasch commented on May 18, 2024

Yeah, that's my plan. I think I'll add something to our web app first, see how it fares, and then maybe extract it into ruby-kafka. My main concerns are getting the periodic wakeup to work and ensuring that messages are sent on shutdown.

from ruby-kafka.

mensfeld avatar mensfeld commented on May 18, 2024

ensuring that messages are sent on shutdown.

You could just expose a trigger for that action and the shutdown implementation could differ for apps that use it. Something like (naming taken from newrelic rpm): Kafka.harvester.flush!

from ruby-kafka.

dasch avatar dasch commented on May 18, 2024

We have a similar abstraction in our code base: KafkaLog. It's a singleton and you call flush on it.

from ruby-kafka.

mensfeld avatar mensfeld commented on May 18, 2024

@dasch just remember to add a mutex (probably don't have to tell you that but oh well ;) ) - so a multiple flash from many threads won't occur

from ruby-kafka.

dasch avatar dasch commented on May 18, 2024

Yeah, the flush would happen from the background thread itself, so that wouldn't be an issue. I think I'll just add a thread-safe queue between the main and the background threads, that usually makes things simpler.

from ruby-kafka.

Related Issues (20)

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.