Skip to content

Conversation

@gpauloski
Copy link
Collaborator

Description

Adds the KafkaPublisher and KafkaSubscriber interfaces for using Kafka with the ProxyStore stream interface.

Fixes

Type of Change

  • Breaking Change (fix or enhancement which changes existing semantics of the public interface)
  • Enhancement (new features or improvements to existing functionality)
  • Bug (fixes for a bug or issue)
  • Internal (refactoring, style changes, testing, optimizations)
  • Documentation update (changes to documentation or examples)
  • Package (dependencies, versions, package metadata)
  • Development (CI workflows, pre-commit, linters, templates)
  • Security (security related changes)

Testing

Added unit tests using mock Kafka interfaces.

Also added the testing/scripts/kafka_pubsub.py script for running against an actual Kaka service. I used the following docker-compose.yml from https://sahansera.dev/setting-up-kafka-locally-for-testing/ to test it.

version: '3'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:7.0.1
    container_name: zookeeper
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  broker:
    image: confluentinc/cp-kafka:7.0.1
    container_name: broker
    ports:
    # To learn about configuring Kafka for access across networks see
    # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
      - "9092:9092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1

Pull Request Checklist

Please confirm the PR meets the following requirements.

  • Tags added to PR (e.g., breaking, bug, enhancement, internal, documentation, package, development, security).
  • Code changes pass pre-commit (e.g., mypy, ruff, etc.).
  • Tests have been added to show the fix is effective or that the new feature works.
  • New and existing unit tests pass locally with the changes.
  • Docs have been updated and reviewed if relevant.

Added unit tests using mock Kafka clients, but also added a
script to test the basic functionality against a real Kafka broker.
@gpauloski gpauloski added the enhancement New features or improvements to existing functionality label Jan 18, 2024
kafka-python 2.0.2 (the latest release at this time) is not compatible
with Python 3.12. There's not really any option here but to skip the
tests and omit the relevant files from coverage. It's a bit ugly, but it
seems like there may be an updated version soon.

dpkp/kafka-python#2408 (comment)
@gpauloski gpauloski merged commit 24b1bd4 into main Jan 18, 2024
@gpauloski gpauloski deleted the issue-449 branch January 18, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New features or improvements to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add KafkaPublisher/KafkaSubscriber implementations for Kafka

2 participants