Skip to content

Commit 85963e0

Browse files
authored
2.1.1 (#44)
* Update confluent-kafka to 2.1.0 * Split dependencies into extra packages * Install librdkafka-dev in generate docs workflow * Update to 2.1.1
1 parent 429cb98 commit 85963e0

File tree

8 files changed

+53
-22
lines changed

8 files changed

+53
-22
lines changed

.github/workflows/generate_docs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.x'
20-
- name: Install python requirements
16+
# This latest python way can't find the librdkafka.h files
17+
# - name: Set up Python
18+
# uses: actions/setup-python@v4
19+
# with:
20+
# python-version: '3.x'
21+
- name: Install requirements
2122
run: pip install .
2223
- name: Generate keyword documentation
2324
run: python3 -m robot.libdoc -f html src/ConfluentKafkaLibrary docs/index.html

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ jobs:
2828
- name: Spin up kafka
2929
run: cd examples && docker-compose up -d && cd ..
3030
- name: Install python requirements
31-
run: pip install .
31+
run: pip install .[all]
3232
- name: Wait for services
3333
run: while [ -n "$(docker container ls -a | grep starting)" ]; do sleep 2; done;
3434
- name: Docker inspect
3535
run: docker inspect --format "{{json .State.Health.Status }}" $(docker-compose -f examples/docker-compose.yml ps -q)
36+
- name: Show python version
37+
run: python3 --version
3638
- name: Execute tests
3739
run: python3 -m robot -d ./docs examples/
3840
continue-on-error: true

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ To install the library, run the following command:
2222
pip install robotframework-confluentkafkalibrary
2323
```
2424

25+
Extra packages:
26+
* [avro] = ['fastavro >= 1.3.2', 'avro-python3 >= 1.10.1']
27+
* [json] = ['jsonschema >= 3.2.0']
28+
* [protobuf] = ['protobuf >= 4.22.0']
29+
30+
To install all dependencies use `[all]` extension like:
31+
32+
```
33+
pip install robotframework-confluentkafkalibrary[all]
34+
```
35+
2536
## Usage
2637

2738
In most cases, you can refer to the [confluent-kafka-python documentation](https://docs.confluent.io/platform/current/clients/confluent-kafka-python/html/index.html) for guidance. Every keyword in ConfluentKafkaLibrary is designed to match the corresponding Python functions. If you are unsure about the pre-configured keywords, please visit the [robotframework-ConfluentKafkaLibrary documentation](https://robooo.github.io/robotframework-ConfluentKafkaLibrary/). The Kafka team maintains the up-to-date documentation for configuration properties and their values [here](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md).

setup.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
Confluent Kafka wrapped in Robot Framework.
1111
"""[1:-1]
1212

13+
AVRO_REQUIRES = ['fastavro >= 1.3.2', 'avro-python3 >= 1.10.1']
14+
JSON_REQUIRES = ['jsonschema >= 3.2.0']
15+
PROTO_REQUIRES = ['protobuf >= 4.22.0']
16+
ALL = AVRO_REQUIRES + JSON_REQUIRES + PROTO_REQUIRES
1317
setup(name = 'robotframework-confluentkafkalibrary',
1418
version = VERSION,
1519
description = 'Confluent Kafka library for Robot Framework',
@@ -28,13 +32,15 @@
2832
],
2933
install_requires = [
3034
'robotframework >= 3.2.1',
31-
'confluent-kafka == 2.0.2',
35+
'confluent-kafka == 2.1.1',
3236
'requests >= 2.25.1',
33-
'avro-python3 >= 1.10.1',
34-
'fastavro >= 1.3.2',
35-
'jsonschema >= 3.2.0',
36-
'protobuf >= 4.22.0'
3737
],
38+
extras_require={
39+
'all': ALL,
40+
'avro': AVRO_REQUIRES,
41+
'json': JSON_REQUIRES,
42+
'protobuf': PROTO_REQUIRES,
43+
},
3844
package_dir = {'' : 'src'},
39-
packages = ['ConfluentKafkaLibrary'],
45+
packages = ['ConfluentKafkaLibrary'],
4046
)

src/ConfluentKafkaLibrary/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
from confluent_kafka.schema_registry import SchemaRegistryClient
44
from confluent_kafka.admin import AdminClient, NewTopic, NewPartitions, ConfigResource
55
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
6-
76
from .consumer import KafkaConsumer
87
from .producer import KafkaProducer
98
from .admin_client import KafkaAdminClient
10-
from .serialization import Serializer, Deserializer
119
from .version import VERSION
1210

11+
IMPORTS = KafkaConsumer, KafkaProducer, KafkaAdminClient
12+
try:
13+
from .serialization import Serializer, Deserializer
14+
IMPORTS += Serializer, Deserializer
15+
except ImportError:
16+
pass
1317

1418
#class ConfluentKafkaLibrary(KafkaConsumer, KafkaProducer, Serializer, Deserializer):
15-
class ConfluentKafkaLibrary(KafkaConsumer, KafkaProducer, KafkaAdminClient, Serializer, Deserializer):
19+
class ConfluentKafkaLibrary(*IMPORTS):
1620
"""ConfluentKafkaLibrary is a Robot Framework library which wraps up
1721
[https://github.com/confluentinc/confluent-kafka-python | confluent-kafka-python].
1822
Library supports more functionality like running more clients based on `group_id`
@@ -89,7 +93,7 @@ def _set_globals_variables_if_robot_running(self):
8993
BuiltIn().set_global_variable('${ADMIN_RESOURCE_GROUP}', confluent_kafka.admin.RESOURCE_GROUP)
9094
BuiltIn().set_global_variable('${ADMIN_RESOURCE_TOPIC}', confluent_kafka.admin.RESOURCE_TOPIC)
9195

92-
BuiltIn().set_global_variable('${CONSUMER_GROUP_STATE_UNKNOWN}', confluent_kafka.ConsumerGroupState.UNKOWN)
96+
BuiltIn().set_global_variable('${CONSUMER_GROUP_STATE_UNKNOWN}', confluent_kafka.ConsumerGroupState.UNKNOWN)
9397
BuiltIn().set_global_variable('${CONSUMER_GROUP_STATE_PREPARING_REBALANCING}', confluent_kafka.ConsumerGroupState.PREPARING_REBALANCING)
9498
BuiltIn().set_global_variable('${CONSUMER_GROUP_STATE_COMPLETING_REBALANCING}', confluent_kafka.ConsumerGroupState.COMPLETING_REBALANCING)
9599
BuiltIn().set_global_variable('${CONSUMER_GROUP_STATE_STABLE}', confluent_kafka.ConsumerGroupState.STABLE)

src/ConfluentKafkaLibrary/consumer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
from threading import Thread
33
from confluent_kafka import Consumer, KafkaException, KafkaError, TopicPartition
44
from confluent_kafka import DeserializingConsumer
5-
from confluent_kafka.avro.serializer import SerializerError
6-
from confluent_kafka.avro import AvroConsumer
75
from confluent_kafka.admin import AdminClient
86

7+
try:
8+
from confluent_kafka.avro.serializer import SerializerError
9+
from confluent_kafka.avro import AvroConsumer
10+
except ImportError:
11+
pass
12+
913

1014
class GetMessagesThread(Thread):
1115

src/ConfluentKafkaLibrary/producer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import uuid
22
import os
3-
from avro import schema
43
from confluent_kafka import SerializingProducer
54
from confluent_kafka import Producer
6-
from confluent_kafka import avro
7-
from confluent_kafka.avro import AvroProducer
85

6+
try:
7+
from avro import schema
8+
from confluent_kafka import avro
9+
from confluent_kafka.avro import AvroProducer
10+
except ImportError:
11+
pass
912

1013
class KafkaProducer():
1114

src/ConfluentKafkaLibrary/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '2.0.2-4'
1+
VERSION = '2.1.1-1'

0 commit comments

Comments
 (0)