Giter Club home page Giter Club logo

Comments (5)

mateusjunges avatar mateusjunges commented on August 24, 2024

Hi @nickpoulos

I was curious how the published config file was actually used within the library.

It's used to define default configurations for kafka consumers/producers.

I see there is a Kafka Consume command that is not mentioned in the documentation. The way it is written now, this command does not know how to handle the messages it is consuming.
How do we pass a message handler into this command?

You have a good point here. The way it's written now, it's impossible to pass the message handler to the artisan consumer. I think we can have a default handler within config/kafka.php but also allow to pass the class via command options, which would allow using the built-in command via supervisor specifying a different handler for each message type.

Feel free to submit a PR if you want to, or i'll work on that after work.

Thanks!

from laravel-kafka.

nickpoulos avatar nickpoulos commented on August 24, 2024

Hi @mateusjunges thanks for the quick reply. I started creating the PR, but had some questions about the --consumer option in the command. How was this designed to be used originally? It seems if we can pass in a Consumer class, the handler could be set there first.

What is the purpose of the consumer property within the Config class?

from laravel-kafka.

mateusjunges avatar mateusjunges commented on August 24, 2024

@nickpoulos actually, the consumer option was created to be the message handler, and this consumer must extend the Junges\Kafka\Contracts\Consumer class. Within ConsumerBuilder.php, the config class receives a CallableConsumer instance for the consumer option, which is created using the handler passed and the middlewares, if any. For the KafkaConsumerCommand, it isn't working as expected. I'm pretty sure i forgot this class completely over the last updates i made to this library. Also, the command option should be called handler, not consumer, since the consumer is created using the message handler. It's not clear and one point in it's fabor is that even i got confused about it. So, it's not impossible to pass a message handler to the command, but the command itself isn't working and needs some fixes. The Consumer class now users two parameters: the config and the message deserializer, but the command only pass the configuration. I think it would be nice to allow the user to choose which deserializer to be used while consuming messages using this command (using command arguments/options). Sorry about the answer i gave you in my previous comment, now looking at the code carefully i understand whats happening here.

from laravel-kafka.

nickpoulos avatar nickpoulos commented on August 24, 2024

Ok that all makes sense to me for the most part.

But there also seems to be some confusion around Options/Config?

It seems like we want to be able to pass in options via the CLI command, but then if those options are not provided we want to fall back to whatever is in config. And you started making the Options class to handle this merging? Is that correct? It is hard to tell because it appears unfinished, but I can continue down this route and fix the discrepancies if you agree.

Another idea I had was, rather than provide more and more options via the CLI, what if we setup our /config/kafka.php more similar to how Laravel's mysql options are setup? Ex: you would create a named connection the config file, and then for the CLI command, we pass in a connection param.

Let me know what you think, I can continue down either path here.

from laravel-kafka.

mateusjunges avatar mateusjunges commented on August 24, 2024

It seems like we want to be able to pass in options via the CLI command, but then if those options are not provided we want to fall back to whatever is in config. And you started making the Options class to handle this merging? Is that correct? It is hard to tell because it appears unfinished, but I can continue down this route and fix the discrepancies if you agree.

Yes, the Options class receives the options passed to the artisan command, and if it's not present, we should fall back to config defaults.

Another idea I had was, rather than provide more and more options via the CLI, what if we setup our /config/kafka.php more similar to how Laravel's mysql options are setup? Ex: you would create a named connection the config file, and then for the CLI command, we pass in a connection param.

I think the connection option is a really good idea, so we can create connections in kafka.php and it decrease the number of options we need to pass via cli.

from laravel-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.