Skip to content

Cleanup naming #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/about/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ draft: false
[![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)
![Supported PHP versions: 7.x .. 8.x](https://img.shields.io/badge/php-7.x%20..%208.x-blue.svg)
[![License: BSD-3](https://img.shields.io/badge/License-BSD--3-green.svg)](https://github.com/php-kafka/php-simple-kafka-client/blob/main/LICENSE)
[![Join the chat at https://gitter.im/php-kafka/php-simple-kafka-client](https://badges.gitter.im/php-kafka/php-simple-kafka-client.svg)](https://gitter.im/php-kafka/php-simple-kafka-client?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This extension provides ways to interact with Apache Kafka.
You can find some examples for producer and consumer [here](https://github.com/php-kafka/php-kafka-examples/tree/main/src/ext-php-simple-kafka-client)
Expand Down
2 changes: 1 addition & 1 deletion content/configuration/dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dumps the current configuration

## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->set('auto.offset.reset', 'earliest');
$conf->dump();
```
2 changes: 1 addition & 1 deletion content/configuration/set.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Set a configuration value

## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->set('auto.offset.reset', 'earliest');
```
2 changes: 1 addition & 1 deletion content/configuration/setDrMsgCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ the message was succesfully delivered or permanently failed delivery

## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setDrMsgCb(
function (Producer $kafka, Message $message) {
if (RD_KAFKA_RESP_ERR_NO_ERROR !== $message->err) {
Expand Down
4 changes: 2 additions & 2 deletions content/configuration/setErrorCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ that non-critical errors will be retried by `libdrkafka`

## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setErrorCb(
function (Kafka\Kafka $kafka, $errorCode, $reason) {
function (SimpleKafkaClient\Kafka $kafka, $errorCode, $reason) {
//do something
}
);
Expand Down
4 changes: 2 additions & 2 deletions content/configuration/setLogCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Set a log callback
You will get events according to the `log_level` setting
## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setLogCb(
function (Kafka\Kafka $kafka, int $level, string $facility, string $message) {
function (SimpleKafkaClient\Kafka $kafka, int $level, string $facility, string $message) {
//do something
}
);
Expand Down
4 changes: 2 additions & 2 deletions content/configuration/setOffsetCommitCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ this callback will be called with `err == RD_KAFKA_RESP_ERR__NO_OFFSET`
which is not to be considered an error.
## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setOffsetCommitCb(
function (Kafka\Kafka $kafka, int $errorCode, array $topicPartition) {
function (SimpleKafkaClient\Kafka $kafka, int $errorCode, array $topicPartition) {
if (RD_KAFKA_RESP_ERR_NO_ERROR === $errorCode) {
echo 'Commit was successful';
} else {
Expand Down
4 changes: 2 additions & 2 deletions content/configuration/setRebalanceCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ to the application's callback.

## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setRebalanceCb(
function (Kafka\Consumer $kafka, int $errorCode, array $partitions = null) {
function (SimpleKafkaClient\Consumer $kafka, int $errorCode, array $partitions = null) {
case RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS:
$kafka->assign($partitions);
break;
Expand Down
4 changes: 2 additions & 2 deletions content/configuration/setStatsCb.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Set a statistics callback
The statistics callback is triggered every `statistics.interval.ms` (needs to be configured separately).
## Example
```php
$conf = new Kafka\Configuration();
$conf = new SimpleKafkaClient\Configuration();
$conf->setStatsCb(
function (Kafka\Kafka $kafka, string $json, int $jsonLength) {
function (SimpleKafkaClient\Kafka $kafka, string $json, int $jsonLength) {
//do something
}
);
Expand Down
4 changes: 2 additions & 2 deletions content/consumer/__construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function __construct(Configuration $configuration) {}
Get a consumer instance
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
```
8 changes: 4 additions & 4 deletions content/consumer/assign.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Atomic assignment of partitions to consume.
The new `partitions` will replace the existing assignment.
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->assign(
[
new Kafka\TopicPartition('test-topic', 1, 3000),
new Kafka\TopicPartition('test-topic', 2, 3009)
new SimpleKafkaClient\TopicPartition('test-topic', 1, 3000),
new SimpleKafkaClient\TopicPartition('test-topic', 2, 3009)
]
);
```
4 changes: 2 additions & 2 deletions content/consumer/close.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ the consumer has revoked its assignment, calling the rebalance callback
if it is configured, committed offsets to broker, and left the consumer group. The maximum blocking time is roughly limited to session.timeout.ms.
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->close();
```
10 changes: 5 additions & 5 deletions content/consumer/commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ draft: false
## Description
```php
/**
* @throws Kafka\Exception
* @throws SimpleKafkaClient\Exception
*/
public function commit($messageOrOffsets): void {}
```
Commit offsets synchronously, block until offsets are
committed or the commit fails and an exception is thrown.
## Parameter details
- If `null` is passed, latest offsets for the current assignment will be committed
- Ìf a `Kafka\Message` is passed, commit offset for a single topic+partition based on the message
- If an array of `Kafka\TopicPartition` is passed, commit offsets for the provided list of partitions
- Ìf a `SimpleKafkaClient\Message` is passed, commit offset for a single topic+partition based on the message
- If an array of `SimpleKafkaClient\TopicPartition` is passed, commit offsets for the provided list of partitions

## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$message = $consumer->consume(20000);

if (RD_KAFKA_RESP_ERR_NO_ERROR !== $message->err) {
Expand Down
8 changes: 4 additions & 4 deletions content/consumer/commitAsync.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public function commitAsync($messageOrOffsets): void {}
Commit offsets asynchronously
## Parameter details
- If `null` is passed, latest offsets for the current assignment will be committed
- Ìf a `Kafka\Message` is passed, commit offset for a single topic+partition based on the message
- If an array of `Kafka\TopicPartition` is passed, commit offsets for the provided list of partitions
- Ìf a `SimpleKafkaClient\Message` is passed, commit offset for a single topic+partition based on the message
- If an array of `SimpleKafkaClient\TopicPartition` is passed, commit offsets for the provided list of partitions

## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$message = $consumer->consume(20000);

if (RD_KAFKA_RESP_ERR_NO_ERROR !== $message->err) {
Expand Down
4 changes: 2 additions & 2 deletions content/consumer/consume.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Registered callbacks will be automaically called `rebalanceCallback`, `logCallba
On error `$message->err` will not be `RD_KAFKA_ERR_NO_ERROR` but contain the acutal error code.
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$message = $consumer->consume(20000);
```
{{< hint info >}}
Expand Down
8 changes: 4 additions & 4 deletions content/consumer/getAssignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public function getAssignment(): array {}
Returns the current partition assignment
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->assign(
[
new Kafka\TopicPartition('test-topic', 1, 3000),
new Kafka\TopicPartition('test-topic', 2, 3009)
new SimpleKafkaClient\TopicPartition('test-topic', 1, 3000),
new SimpleKafkaClient\TopicPartition('test-topic', 2, 3009)
]
);
var_dump($consumer->getAssignment());
Expand Down
4 changes: 2 additions & 2 deletions content/consumer/getCommittedOffsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public function getCommittedOffsets(array $topics, int $timeoutMs): array {}
Returns the committed offsets for topics and partitions for a consumer group
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicPartition = new TopicPartition('test-topic', 0);
var_dump($consumer->getCommittedOffsets([$topicPartition], 10000));
```
4 changes: 2 additions & 2 deletions content/consumer/getMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function getMetadata(bool $allTopics, int $timeoutMs, ConsumerTopic $topic = nul
Get metadata for all topics or a single topic
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicHandle = $consumer->getTopicHandle('test-topic');
$singleTopicMetadata = $consumer->metadata(true, $topicHandle, 10000);
```
4 changes: 2 additions & 2 deletions content/consumer/getOffsetPositions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The offset field of each requested partition will be set to the offset of the la
If there was no previous message `RD_KAFKA_OFFSET_INVALID` will be returned
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicPartition = new TopicPartition('test-topic', 0);
$topicPartitionsWithOffsets = $consumer->getOffsetPositions([$topicPartition]));
```
4 changes: 2 additions & 2 deletions content/consumer/getSubscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public function getSubscription(): array {}
Return topic names to which the consumer is currently subscribed to
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->subscribe(['test-topic']);
var_dump($consumer->getSubscription());
```
4 changes: 2 additions & 2 deletions content/consumer/getTopicHandle.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Get a topic handle for a given topic name. A topic handle is needed
for example to query metadata from the broker
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicHandle = $consumer->getTopicHandle('test-topic');

// use the topic handle for further calls, e.g. to query metadata
Expand Down
4 changes: 2 additions & 2 deletions content/consumer/offsetForTimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ timestamp is greater than or equal to the given timestamp in the
corresponding partition.
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicPartition = new TopicPartition('test-topic', 0, strtotime("-1 week"));
$offsetsOneWeekAgo = $consumer->offsetForTimes([$topicPartition], 10000);
```
4 changes: 2 additions & 2 deletions content/consumer/queryWatermarkOffsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Query broker for low (oldest) and high (newest) offsets for a partition
$low = 0;
$high = 0;

$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$topicPartition = new TopicPartition('test-topic', 0, strtotime("-1 week"));
$consumer->queryWatermarkOffsets('test-topic', 0, int &$low, int &$high, 10000);
```
4 changes: 2 additions & 2 deletions content/consumer/subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Any previous subscription will be unassigned and unsubscribed first.

## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->subscribe(['test-topic']);
```
4 changes: 2 additions & 2 deletions content/consumer/unsubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Unsubscribe from the current subscriptions

## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$consumer = new Kafka\Consumer($conf);
$consumer = new SimpleKafkaClient\Consumer($conf);
$consumer->subscribe(['test-topic']);
$consumer->unsubscribe();
```
8 changes: 5 additions & 3 deletions content/installation/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ date: 2020-12-27T22:09:37+01:00
draft: false
---
## Installation with PECL
Not yet support (WIP)
```
pecl install simple_kafka_client
```

### Manual installation
```bash
git clone https://github.com/php-kafka/php-simple-kafka-client.git
cd php-simple-kafka-client
phpize && ./configure && make -j5 all && make install
```
In your `php/conf.d` folder add a `kafka.ini` with the following:
In your `php/conf.d` folder add a `simple_kafka_client.ini` with the following:
```ini
extension=kafka.so
extension=simple_kafka_client.so
```
2 changes: 1 addition & 1 deletion content/kafkaException/__construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
Create new `KafkaErrorException`, this can be helpful for transaction tests
## Example
```php
throw new Kafka\KafkaErrorException(
throw new SimpleKafkaClient\KafkaErrorException(
'Some error message',
88,
'This is a detailed error string',
Expand Down
6 changes: 3 additions & 3 deletions content/kafkaException/getErrorString.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public function getErrorString(): string {}
Get error description for this exception
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$producer = new Kafka\Producer($conf);
$producer = new SimpleKafkaClient\Producer($conf);
try {
$producer->initTransactions(10000);
} catch (Kafka\KafkaErrorException $e) {
} catch (SimpleKafkaClient\KafkaErrorException $e) {
echo $e->getErrorString();
}
```
6 changes: 3 additions & 3 deletions content/kafkaException/isFatal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public function isFatal(): bool {}
Check if it is a fatal exception
## Example
```php
$conf = Kafka\Configuration();
$conf = SimpleKafkaClient\Configuration();
$conf->set('metadata.broker.list', 'kafka:9092');
$producer = new Kafka\Producer($conf);
$producer = new SimpleKafkaClient\Producer($conf);
try {
$producer->initTransactions(10000);
} catch (Kafka\KafkaErrorException $e) {
} catch (SimpleKafkaClient\KafkaErrorException $e) {
if ($e->isFatal()) {
// non-recoverable error
}
Expand Down
Loading