Skip to main content

Python adapter for Kafka

Project description

NAAS-PYTHON-KAFKA

This is the Kafka adapter for Python: it allows you to easily connect Python services to Apache Kafka via Python.

The implementation is a wrapper around Confluent-Kafka-Python:

  • AVRO schema's and messages: both key's and values should have a schema. as explained here.
  • Kafka consumer and producer for the test-bed topics.
  • Management
    • Heartbeat (topic: system-heartbeat), so you know which clients are online. Each time the test-bed-adapter is executed, it starts a heartbeat process to notify the its activity to other clients.

Installation

You need to install Python 3+.

To run the examples you will need to install the dependencies specified on the file requirements.txt.

For that, run

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt # Or instead of `pip`, use `pip3`

from the project folder.

Examples and usage

  • url_producer: Creates a message with 4 URLs to RSS feeds on the topic ('system_rss_urls')
  • rss_producer: Listens to url messages ('system_rss_urls') and produces RSS messages ('system_rss_urls')
  • rss_consumer: Listens to RSS messages ('system_rss_urls') and prints them to console.

Uploading to PyPi

  1. Ensure you have the necessary tools installed: Make sure you have setuptools and wheel installed. You can install them using pip:

    # Build the distribution files: In the root directory of your project, run the following command to build the distribution files (wheel and source distribution):
    pip install setuptools wheel
    
  2. Build the distribution files: In the root directory of your project, run the following command to build the distribution files (wheel and source distribution):

    # This command will generate the distribution files inside the dist directory.
    python setup.py sdist bdist_wheel
    

    This command will generate the distribution files inside the dist directory.

  3. Register an account on PyPI: If you haven't done so already, create an account on PyPI and verify your email address.

  4. Install and configure twine: Install twine, a tool used to upload packages to PyPI, using pip:

    # Upload the package to PyPI: Use twine to upload the distribution files to PyPI:
    pip install twine
    
  5. Upload the package to PyPI: Use twine to upload the distribution files to PyPI:

    # This command will prompt you to enter your PyPI username and password. Once provided, twine will upload the distribution files to PyPI.
    # Use $HOME/.pypirc if you want to use a different configuration file.
    twine upload --repository osint-python-test-bed-adapter dist/*
    

    This command will prompt you to enter your PyPI username and password. Once provided, twine will upload the distribution files to PyPI.

  6. Verify the package on PyPI: Visit your package page on PyPI to ensure that the package has been successfully uploaded and published.

    Remember to update the version number in your setup.py file for each new release to avoid conflicts.

In short:

# Install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Create a new release after updating the setup.py package version number
rm -rf dist
python setup.py sdist bdist_wheel
twine upload --repository osint-python-test-bed-adapter dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osint_python_test_bed_adapter-2.6.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osint_python_test_bed_adapter-2.6.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file osint_python_test_bed_adapter-2.6.1.tar.gz.

File metadata

File hashes

Hashes for osint_python_test_bed_adapter-2.6.1.tar.gz
Algorithm Hash digest
SHA256 852c1ed88921a2caafbfc3666d3bff1e94383a9f66f1d7a7ebe5f1944bca4475
MD5 4fdc70aee593da7c5b6f0f98584df8f7
BLAKE2b-256 021d27ec44ce20f804d3e223bef37ff660372776049eb80c615785541d68e85d

See more details on using hashes here.

File details

Details for the file osint_python_test_bed_adapter-2.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for osint_python_test_bed_adapter-2.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a91ed03edfafa393db4afdcd68c8dd44b28a63f36466a44368928d9ad2a44edf
MD5 7f62e38b34548d8a63dc4d267c64ccd7
BLAKE2b-256 e8c708f3bebafc3820de0fdf649c7802fd2e60ea3792560005c9a8ebfdebb473

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page