|
| 1 | +Command-Line Interface |
| 2 | +********************** |
| 3 | + |
| 4 | +kafka-python ships simple command-line interfaces for consumer, producer, |
| 5 | +and admin clients. They can be invoked either as the ``kafka-python`` |
| 6 | +console script or as module entry points: |
| 7 | + |
| 8 | +.. code-block:: bash |
| 9 | +
|
| 10 | + kafka-python consumer -b localhost:9092 -t my-topic |
| 11 | + kafka-python producer -b localhost:9092 -t my-topic |
| 12 | + kafka-python admin -b localhost:9092 cluster describe |
| 13 | +
|
| 14 | + # equivalent module invocations |
| 15 | + python -m kafka.consumer -b localhost:9092 -t my-topic |
| 16 | + python -m kafka.producer -b localhost:9092 -t my-topic |
| 17 | + python -m kafka.admin -b localhost:9092 cluster describe |
| 18 | +
|
| 19 | +The ``kafka-python admin`` command, in particular, is a convenient |
| 20 | +alternative to the apache kafka ``bin/`` scripts when a compatible JVM is |
| 21 | +not available. |
| 22 | + |
| 23 | +.. toctree:: |
| 24 | + :maxdepth: 2 |
| 25 | + |
| 26 | + consumer |
| 27 | + producer |
| 28 | + admin |
| 29 | + |
| 30 | + |
| 31 | +Common Options |
| 32 | +============== |
| 33 | + |
| 34 | +All three commands share a common set of connection, logging, and |
| 35 | +configuration options. They are documented in full on the individual |
| 36 | +command pages; the summary below highlights the most commonly used |
| 37 | +flags. |
| 38 | + |
| 39 | +Connection |
| 40 | +---------- |
| 41 | + |
| 42 | +``-b/--bootstrap-servers HOST:PORT`` |
| 43 | + One or more bootstrap servers used to discover the rest of the |
| 44 | + cluster. May be supplied multiple times. |
| 45 | + |
| 46 | +``-S/--security-protocol`` |
| 47 | + One of ``PLAINTEXT``, ``SSL``, ``SASL_PLAINTEXT``, ``SASL_SSL``. |
| 48 | + Defaults to ``PLAINTEXT``. |
| 49 | + |
| 50 | +``-M/--sasl-mechanism`` |
| 51 | + One of ``PLAIN``, ``GSSAPI``, ``OAUTHBEARER``, ``SCRAM-SHA-256``, |
| 52 | + ``SCRAM-SHA-512``. Defaults to ``PLAIN``. |
| 53 | + |
| 54 | +``-U/--sasl-user`` / ``-P/--sasl-password`` |
| 55 | + Credentials for SASL ``PLAIN`` and ``SCRAM-*`` mechanisms. |
| 56 | + |
| 57 | +Logging |
| 58 | +------- |
| 59 | + |
| 60 | +``-l/--log-level`` |
| 61 | + Python ``logging`` level (``DEBUG``, ``INFO``, ...). Defaults to |
| 62 | + ``CRITICAL`` so the CLI is quiet by default. |
| 63 | + |
| 64 | +``-L/--enable-logger`` / ``-D/--disable-logger`` |
| 65 | + Selectively turn on or off a single logger by name. Both flags may |
| 66 | + be supplied multiple times. |
| 67 | + |
| 68 | +Extended Configuration |
| 69 | +---------------------- |
| 70 | + |
| 71 | +``-C/--extra-config key=value`` |
| 72 | + Pass arbitrary keyword arguments through to the underlying client |
| 73 | + constructor (:class:`~kafka.KafkaConsumer`, |
| 74 | + :class:`~kafka.KafkaProducer`, or |
| 75 | + :class:`~kafka.KafkaAdminClient`). Values that parse as ``int``, |
| 76 | + ``True``, ``False``, or ``None`` are converted; everything else is |
| 77 | + passed through as a string. May be supplied multiple times. |
| 78 | + |
| 79 | + .. code-block:: bash |
| 80 | +
|
| 81 | + kafka-python consumer -b localhost:9092 -t foo \ |
| 82 | + -C auto_offset_reset=earliest \ |
| 83 | + -C consumer_timeout_ms=1000 |
0 commit comments