Skip to content

Commit 2f0c875

Browse files
committed
save work
1 parent add3cda commit 2f0c875

17 files changed

+284
-1
lines changed

content/about/_index.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@ title: "About"
33
date: 2020-12-27T22:09:37+01:00
44
draft: false
55
---
6+
7+
[![Supported librdkafka versions: >= 1.4.0](https://img.shields.io/badge/librdkafka-%3E%3D%201.4.0-blue.svg)](https://github.com/edenhill/librdkafka/releases)
8+
[![Supported Kafka versions: >= 0.9](https://img.shields.io/badge/kafka-%3E%3D%200.9-blue.svg)](https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#broker-version-compatibility)
9+
![Supported PHP versions: 7.x .. 8.x](https://img.shields.io/badge/php-7.x%20..%208.x-blue.svg)
10+
[![License: BSD-3](https://img.shields.io/badge/License-BSD--3-green.svg)](https://github.com/php-kafka/php-kafka/blob/main/LICENSE)
11+
612
This extension provides ways to interact with Apache Kafka.
713
It uses [librdkafka](https://github.com/edenhill/librdkafka) for binding and was inspired by [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka).

content/consumer/__construct.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "__construct"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
public function __construct(Configuration $configuration) {}
9+
```
10+
Get a consumer instance
11+
## Example
12+
```php
13+
$conf = Kafka\Configuration();
14+
$conf->set('metadata.broker.list', 'kafka:9092');
15+
$consumer = new Kafka\Consumer($conf);
16+
```

content/consumer/assign.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: "assign"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
public function assign(array $topics): void {}
9+
```
10+
Atomic assignment of partitions to consume.
11+
The new `partitions` will replace the existing assignment.
12+
## Example
13+
```php
14+
$conf = Kafka\Configuration();
15+
$conf->set('metadata.broker.list', 'kafka:9092');
16+
$consumer = new Kafka\Consumer($conf);
17+
$consumer->assign(
18+
[
19+
new Kafka\TopicPartition('test-topic', 1, 3000),
20+
new Kafka\TopicPartition('test-topic', 2, 3009)
21+
]
22+
);
23+
```

content/consumer/close.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: "close"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
public function close(): void {}
9+
```
10+
Close down the Consumer. This call will block until
11+
the consumer has revoked its assignment, calling the rebalance callback
12+
if it is configured, committed offsets to broker, and left the consumer group. The maximum blocking time is roughly limited to session.timeout.ms.
13+
## Example
14+
```php
15+
$conf = Kafka\Configuration();
16+
$conf->set('metadata.broker.list', 'kafka:9092');
17+
$consumer = new Kafka\Consumer($conf);
18+
$consumer->close();
19+
```

content/consumer/commit.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "commit"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
/**
9+
* @throws Kafka\Exception
10+
*/
11+
public function commit($messageOrOffsets): void {}
12+
```
13+
Commit offsets synchronously, block until offsets are
14+
committed or the commit fails and an exception is thrown.
15+
## Parameter details
16+
- If `null` is passed, latest offsets for the current assignment will be committed
17+
- Ìf a `Kafka\Message` is passed, commit offset for a single topic+partition based on the message
18+
- If an array of `Kafka\TopicPartition` is passed, commit offsets for the provided list of partitions
19+
20+
## Example
21+
```php
22+
$conf = Kafka\Configuration();
23+
$conf->set('metadata.broker.list', 'kafka:9092');
24+
$consumer = new Kafka\Consumer($conf);
25+
$message = $consumer->consume(20000);
26+
27+
if (RD_KAFKA_RESP_ERR_NO_ERROR !== $message->err) {
28+
echo 'An error occured:' . rd_kafka_err2str($message->err) . PHP_EOL;
29+
return;
30+
}
31+
32+
$consumer->commit($message);
33+
```

content/consumer/commitAsync.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: "commitAsync"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
public function commitAsync($messageOrOffsets): void {}
9+
```
10+
Commit offsets asynchronously
11+
## Parameter details
12+
- If `null` is passed, latest offsets for the current assignment will be committed
13+
- Ìf a `Kafka\Message` is passed, commit offset for a single topic+partition based on the message
14+
- If an array of `Kafka\TopicPartition` is passed, commit offsets for the provided list of partitions
15+
16+
## Example
17+
```php
18+
$conf = Kafka\Configuration();
19+
$conf->set('metadata.broker.list', 'kafka:9092');
20+
$consumer = new Kafka\Consumer($conf);
21+
$message = $consumer->consume(20000);
22+
23+
if (RD_KAFKA_RESP_ERR_NO_ERROR !== $message->err) {
24+
echo 'An error occured:' . rd_kafka_err2str($message->err) . PHP_EOL;
25+
return;
26+
}
27+
28+
$consumer->commitAsync($message);
29+
```

content/consumer/consume.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,21 @@ title: "consume"
33
date: 2020-12-27T22:09:37+01:00
44
draft: false
55
---
6-
asdfasf sf as fsd
6+
## Description
7+
```php
8+
public function consume(int $timeoutMs): Message {}
9+
```
10+
Consume message(s) (will also get error events and triggers callbacks)
11+
Registered callbacks will be automaically called `rebalanceCallback`, `logCallback`, etc.
12+
On error `$message->err` will not be `RD_KAFKA_ERR_NO_ERROR` but contain the acutal error code.
13+
## Example
14+
```php
15+
$conf = Kafka\Configuration();
16+
$conf->set('metadata.broker.list', 'kafka:9092');
17+
$consumer = new Kafka\Consumer($conf);
18+
$message = $consumer->consume(20000);
19+
```
20+
{{< hint info >}}
21+
An application should call consume() at regular intervals, even if no messages
22+
are expected, to serve any queued callbacks waiting to be called.
23+
{{< /hint >}}

content/consumer/getAssignment.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getAssignment"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getCommittedOffsets"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/getMetadata.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getMetadata"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getOffsetPositions"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/getSubscription.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getSubscription"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/getTopicHandle.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "getTopicHandle"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/offsetForTimes.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "offsetsForTimes"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "queryWatermarkOffsets"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/subscribe.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "subscribe"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

content/consumer/unsubscribe.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "unsubscribe"
3+
date: 2020-12-27T22:09:37+01:00
4+
draft: false
5+
---
6+
## Description
7+
```php
8+
9+
```
10+
asdf
11+
## Example
12+
```php
13+
14+
```

0 commit comments

Comments
 (0)