Skip to content

feature request: make Message type user-instantiable #1535

@chairmank

Description

@chairmank

Description

This is an enhancement request to make it easier to write tests for user code that uses this client library. In unit tests, it would useful to be create synthetic Message instances without having to read them from a live Kafka cluster with a Consumer.

The current implementation of the Message type does not make it possible to instantiate a Message because the PyTypeObject MessageType definition does not specify the tp_new and tp_init fields.

In contrast, the TopicPartitionType definition does specify these fields, and we can instantiate a TopicPartition.

How to reproduce

Using confluent-kafka-python v2.0.2, I observe the following when I try to call the __init__ method of Message:

>>> import confluent_kafka
>>> confluent_kafka.Message()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create 'cimpl.Message' instances

Metadata

Metadata

Assignees

No one assigned

    Labels

    code:pythonIssues that are specific to Python or versions of Python independent of library logicmaintenanceAny tech debt or routine action tasks that should be tracked with an issuepriority:highMaintainer triage tag for indicating high impact or criticality issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions