Skip to content

Commit 0e2495a

Browse files
authored
add upgrade md (#14)
* add upgrade md * update doc * update doc * update doc * update doc * update readme / upgrade * add avro hint * update upgrade md * formatting * fix typo * add hint * Update UPGRADE.md * Update UPGRADE.md * text changes * fix examples
1 parent 7963a06 commit 0e2495a

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ can help out to understand the internals of this library.
2020

2121
## Installation
2222
```
23-
composer require jobcloud/php-kafka-lib "~0.1"
23+
composer require jobcloud/php-kafka-lib "~1.0"
24+
```
25+
26+
### Enable Avro support
27+
If you need Avro support, run:
28+
```
29+
composer require flix-tech/avro-serde-php "~1.3"
2430
```
2531

2632
## Usage
@@ -132,7 +138,6 @@ $consumer = KafkaConsumerBuilder::create()
132138
)
133139
->withAdditionalBroker('kafka:9092')
134140
->withConsumerGroup('testGroup')
135-
->withTimeout(120 * 10000)
136141
->withAdditionalSubscription('test-topic')
137142
->build();
138143

@@ -172,7 +177,6 @@ $consumer = KafkaConsumerBuilder::create()
172177
)
173178
->withAdditionalBroker('kafka:9092')
174179
->withConsumerGroup('testGroup')
175-
->withTimeout(120 * 10000)
176180
->withAdditionalSubscription('test-topic')
177181
->withConsumerType(KafkaConsumerBuilder::CONSUMER_TYPE_LOW_LEVEL)
178182
->build();
@@ -251,7 +255,6 @@ $consumer = KafkaConsumerBuilder::create()
251255
->withDecoder($decoder)
252256
->withAdditionalBroker('kafka:9092')
253257
->withConsumerGroup('testGroup')
254-
->withTimeout(120 * 10000)
255258
->withAdditionalSubscription('test-topic')
256259
->build();
257260

UPGRADE.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Upgrade to 1.0
2+
3+
## Avro encoding / decoding
4+
Has been removed as a fixed dependency. If you rely on it you need to run
5+
the following in your project:
6+
```
7+
composer require flix-tech/avro-serde-php "~1.3"
8+
```
9+
10+
## Producer improvements
11+
Producer used to poll all events after `produce`, now per default only one
12+
non-blocking poll call will be triggered after `produce`.
13+
This improvement was made so higher throughput can be achieved if needed.
14+
This affects the following classes:
15+
- KafkaProducer
16+
- Added `syncProduce` - waits indefinitely for an event to be polled
17+
- Added `poll` - gives you the ability to poll, especially useful if you disable auto poll for `produce`
18+
- Added `pollUntilQueueSizeReached` - polls until the poll queue has reached a certain size
19+
- Changed `produce`, changed behaviour (see above), has new optional parameters `$autoPoll` and `$pollTimeoutMs`
20+
21+
To achieve the previous default behaviour change (e.g. suited for REST API applications which trigger a message on call):
22+
```
23+
$producer->produce($message);
24+
```
25+
to
26+
```
27+
$producer->produce($message, false);
28+
$producer->pollUntilQueueSizeReached(); // defaults should work fine
29+
```
30+
31+
## Possibility to decode message later (Consumer)
32+
Consume has now a second optional parameter `consume(int $timeoutMs = 10000, bool $autoDecode = true)`.
33+
If set to false, you must decode your message later using `$consumer->decodeMessage($message)`.
34+
For high throughput, you don't need to decode immediately, some decisions can be made
35+
relying on the message headers alone. This helps to leverage that.
36+
37+
## Remove timout from builder / configuration, added timeout parameter to functions (Consumer / Producer)
38+
You were able to set timeout in the builder, but some methods
39+
still had `timeout` as parameter. To avoid confusion, every method
40+
needing a timeout, will now have it as a parameter with a sane default value.
41+
This affects the following classes:
42+
- KafkaConfiguration
43+
- Removed timeout parameter from `__construct()`
44+
- Removed `getTimeout()`
45+
- KafkaConsumerBuilder / KafkaConsumerBuilderInterface
46+
- Removed `withTimeout()`
47+
- KafkaProducerBuilder / KafkaProducerBuilderInterface
48+
- Removed `withPollTimeout()`
49+
- KafkaHighLevelConsumer / KafkaLowLevelConsumer / KafkaConsumerInterface
50+
- Added `$timeoutMs` to `consume()`, default is 10s
51+
- Added `$timeoutMs` to `getMetadataForTopic()`, default is 10s
52+
- KafkaProducer / KafkaProducerInterface
53+
- Added `pollTimeoutMs` to `produce()`, default is 10s
54+
- Added `$timeoutMs` to `getMetadataForTopic()`, default is 10s
55+
56+
## Possibility to avro encode / decode both key and body of a message
57+
The previous default behaviour was to only encode the body of a message.
58+
Now you are also able to encode / decode message keys.
59+
This affects the following classes:
60+
- AvroSchemaRegistry
61+
- Removed `addSchemaMappingForTopic`
62+
- Removed `getSchemaForTopic`
63+
- Added `addBodySchemaMappingForTopic`
64+
- Added `addKeySchemaMappingForTopic`
65+
- Added `getBodySchemaForTopic`
66+
- Added `getKeySchemaForTopic`
67+
- Behaviour change: Trying to get a schema for which no mapping was registered will throw `AvroSchemaRegistryException`
68+
- `getTopicSchemaMapping` will still return an array with mappings but with an additional first key `body` or `key` for the type of the schema
69+
- KafkaMessageInterface
70+
- type of `key` is now mixed
71+
72+
## Default error callback
73+
The default error callback now only throws exceptions for fatal errors.
74+
Other errors will be retried by librdkafka and are only informational.

0 commit comments

Comments
 (0)