Comments (4)
Hi there, thank you!
The steps look like this:
- Add the new command and its options to the
completer.json
file in thekafkashell/data
directory. - 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.
Thanks for the info Shawn. I have couple of questions.
- How do you discover kafka install location? Is it via port#?
- Does this work on a secure environment?
- I notice a decorator @staticmethod being used. Where is that coming from?
from kafka-shell.
Happy to help, @xargs-Pratix!
-
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, yourbootstrap.servers
are most likelylocalhost:9092
. -
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).
-
It's built into python, see this post more information.
Hope that helps!
from kafka-shell.
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
from kafka-shell.
Related Issues (15)
- Add command: kafka-reassign-partitions
- config.yml removed once sing off HOT 2
- Configuration file validation should evaluate environment variables HOT 3
- Add additional docs for working with kafka in docker HOT 9
- cannot launch kafka-shell HOT 6
- More config/properties auto-completions HOT 1
- Add support for `.sh` kafka commands in the PATH HOT 5
- Add command: kafka-replica-verification
- Connect to Remote kafka cluster HOT 4
- Add command: kafka-preferred-replica-election
- Plzzz Add more Easter eggs
- Allow for commands to be piped
- Auto fill `--command-config` for commands
- Does it support ACL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kafka-shell.