Skip to content

Commit a575b38

Browse files
committed
save work
1 parent 2f0c875 commit a575b38

10 files changed

+85
-28
lines changed

content/consumer/getAssignment.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function getAssignment(): array {}
99
```
10-
asdf
10+
Returns the current partition assignment
1111
## Example
1212
```php
13-
13+
$conf = Kafka\Configuration();
14+
$conf->set('metadata.broker.list', 'kafka:9092');
15+
$consumer = new Kafka\Consumer($conf);
16+
$consumer->assign(
17+
[
18+
new Kafka\TopicPartition('test-topic', 1, 3000),
19+
new Kafka\TopicPartition('test-topic', 2, 3009)
20+
]
21+
);
22+
var_dump($consumer->getAssignment());
1423
```

content/consumer/getCommittedOffsets.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function getCommittedOffsets(array $topics, int $timeoutMs): array {}
99
```
10-
asdf
10+
Returns the committed offsets for topics and partitions for a consumer group
1111
## Example
1212
```php
13-
13+
$conf = Kafka\Configuration();
14+
$conf->set('metadata.broker.list', 'kafka:9092');
15+
$consumer = new Kafka\Consumer($conf);
16+
$topicPartition = new TopicPartition('test-topic', 0);
17+
var_dump($consumer->getCommittedOffsets([$topicPartition], 10000));
1418
```

content/consumer/getMetadata.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
function getMetadata(bool $allTopics, int $timeoutMs, ConsumerTopic $topic = null): Metadata {}
99
```
10-
asdf
10+
Get metadata for all topics or a single topic
1111
## Example
1212
```php
13-
13+
$conf = Kafka\Configuration();
14+
$conf->set('metadata.broker.list', 'kafka:9092');
15+
$consumer = new Kafka\Consumer($conf);
16+
$topicHandle = $consumer->getTopicHandle('test-topic');
17+
$singleTopicMetadata = $consumer->metadata(true, $topicHandle, 10000);
1418
```

content/consumer/getOffsetPositions.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function getOffsetPositions(array $topics): array {}
99
```
10-
asdf
10+
The offset field of each requested partition will be set to the offset of the last consumed message + 1
11+
If there was no previous message `RD_KAFKA_OFFSET_INVALID` will be returned
1112
## Example
1213
```php
13-
14+
$conf = Kafka\Configuration();
15+
$conf->set('metadata.broker.list', 'kafka:9092');
16+
$consumer = new Kafka\Consumer($conf);
17+
$topicPartition = new TopicPartition('test-topic', 0);
18+
$topicPartitionsWithOffsets = $consumer->getOffsetPositions([$topicPartition]));
1419
```

content/consumer/getSubscription.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function getSubscription(): array {}
99
```
10-
asdf
10+
Return topic names to which the consumer is currently subscribed to
1111
## Example
1212
```php
13-
13+
$conf = Kafka\Configuration();
14+
$conf->set('metadata.broker.list', 'kafka:9092');
15+
$consumer = new Kafka\Consumer($conf);
16+
$consumer->subscribe(['test-topic']);
17+
var_dump($consumer->getSubscription());
1418
```

content/consumer/getTopicHandle.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function getTopicHandle(string $topic): ConsumerTopic {}
99
```
10-
asdf
10+
Get a topic handle for a given topic name. A topic handle is needed
11+
for example to query metadata from the broker
1112
## Example
1213
```php
14+
$conf = Kafka\Configuration();
15+
$conf->set('metadata.broker.list', 'kafka:9092');
16+
$consumer = new Kafka\Consumer($conf);
17+
$topicHandle = $consumer->getTopicHandle('test-topic');
1318

19+
// use the topic handle for further calls, e.g. to query metadata
20+
$singleTopicMetadata = $consumer->metadata(true, $topicHandle, 10000);
1421
```

content/consumer/offsetForTimes.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function offsetsForTimes(array $topicPartitions, int $timeoutMs): array {}
99
```
10-
asdf
10+
Look up the offsets for the given partitions by timestamp.
11+
The returned offset for each partition is the earliest offset whose
12+
timestamp is greater than or equal to the given timestamp in the
13+
corresponding partition.
1114
## Example
1215
```php
13-
16+
$conf = Kafka\Configuration();
17+
$conf->set('metadata.broker.list', 'kafka:9092');
18+
$consumer = new Kafka\Consumer($conf);
19+
$topicPartition = new TopicPartition('test-topic', 0, strtotime("-1 week"));
20+
$offsetsOneWeekAgo = $consumer->offsetForTimes([$topicPartition], 10000);
1421
```

content/consumer/queryWatermarkOffsets.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function queryWatermarkOffsets(string $topic, int $partition, int &$low, int &$high, int $timeoutMs): void {}
99
```
10-
asdf
10+
Query broker for low (oldest) and high (newest) offsets for a partition
1111
## Example
1212
```php
13+
$low = 0;
14+
$high = 0;
1315

16+
$conf = Kafka\Configuration();
17+
$conf->set('metadata.broker.list', 'kafka:9092');
18+
$consumer = new Kafka\Consumer($conf);
19+
$topicPartition = new TopicPartition('test-topic', 0, strtotime("-1 week"));
20+
$consumer->queryWatermarkOffsets('test-topic, 0, int &$low, int &$high, 10000);
1421
```

content/consumer/subscribe.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function subscribe(array $topics): void {}
99
```
10-
asdf
10+
Subscribe to one or more topics (regexp also supported).
11+
Any previous subscription will be unassigned and unsubscribed first.
12+
1113
## Example
1214
```php
13-
15+
$conf = Kafka\Configuration();
16+
$conf->set('metadata.broker.list', 'kafka:9092');
17+
$consumer = new Kafka\Consumer($conf);
18+
$consumer->subscribe(['test-topic']);
1419
```

content/consumer/unsubscribe.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ draft: false
55
---
66
## Description
77
```php
8-
8+
public function unsubscribe(): void {}
99
```
10-
asdf
10+
Unsubscribe from the current subscriptions
11+
1112
## Example
1213
```php
13-
14+
$conf = Kafka\Configuration();
15+
$conf->set('metadata.broker.list', 'kafka:9092');
16+
$consumer = new Kafka\Consumer($conf);
17+
$consumer->subscribe(['test-topic']);
18+
$consumer->unsubscribe();
1419
```

0 commit comments

Comments
 (0)