Giter Club home page Giter Club logo

Comments (4)

devshawn avatar devshawn commented on July 20, 2024

Hi there, thank you!

The steps look like this:

  1. Add the new command and its options to the completer.json file in the kafkashell/data directory.
  2. Implement new logic in the kafkashell/executor.py class. This class takes the user input when it is submitted. It then matches specific methods based on the input and executes them.

For example, take the kafka-topics command. If a user enters kafka-topics --list in kafka-shell, it will be sent to the executor class. It will match this block on line 59:

        elif command.startswith(valid_command_prefixes):
            self.execute_valid_command(command)

Then, it will match the following block on line 63:

        if command.startswith(constants.COMMAND_KAFKA_TOPICS):
            final_command = self.handle_kafka_topics_command(command)

We then handle the kafka topics command. This is where we automatically add flags such as --bootstrap-servers. This starts on line 166.

    def handle_kafka_topics_command(self, command):
        command += self.handle_bootstrap_or_zookeeper_flag(command)
        command += self.handle_admin_client_settings(command)
        return command

Lastly, we end up with a final_command that gets executed by os.system(final_command) on line 126.

If you want to implement non-Kafka based commands, look at the exit or save methods in the executor for examples.

I hope that helps!

from kafka-shell.

xargs-Pratix avatar xargs-Pratix commented on July 20, 2024

Thanks for the info Shawn. I have couple of questions.

  1. How do you discover kafka install location? Is it via port#?
  2. Does this work on a secure environment?
  3. I notice a decorator @staticmethod being used. Where is that coming from?

from kafka-shell.

devshawn avatar devshawn commented on July 20, 2024

Happy to help, @xargs-Pratix!

  1. It depends on how you've installed kafka. Most kafka installations run on port 9092. If you've installed it on a local machine and have started a kafka cluster, your bootstrap.servers are most likely localhost:9092.

  2. Yes, this can work in a secure environment. If you're talking about a secure kafka cluster, you can pass client/admin config files with the tool (defined in the kafka-shell config file).

  3. It's built into python, see this post more information.

Hope that helps!

from kafka-shell.

xargs-Pratix avatar xargs-Pratix commented on July 20, 2024

I think I got it. You mean that I should add the path to the cert config file in the completer.json like this "kafka-topics --secure-config path": Like in the screenshot

image

from kafka-shell.

Related Issues (15)

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.