-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKafkaConsumerBuilderInterface.php
124 lines (107 loc) · 3.42 KB
/
KafkaConsumerBuilderInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
declare(strict_types=1);
namespace PhpKafka\Consumer;
use PhpKafka\Message\Decoder\DecoderInterface;
interface KafkaConsumerBuilderInterface
{
public const OFFSET_BEGINNING = RD_KAFKA_OFFSET_BEGINNING;
public const OFFSET_END = RD_KAFKA_OFFSET_END;
public const OFFSET_STORED = RD_KAFKA_OFFSET_STORED;
/**
* Adds a broker from which you want to consume
*
* @param string $broker
* @return KafkaConsumerBuilderInterface
*/
public function withAdditionalBroker(string $broker): self;
/**
* Add topic name(s) (and additionally partition(s) and offset(s)) to subscribe to
*
* @param string $topicName
* @param int[] $partitions
* @param integer $offset
* @return KafkaConsumerBuilderInterface
*/
public function withAdditionalSubscription(
string $topicName,
array $partitions = [],
int $offset = self::OFFSET_STORED
): self;
/**
* Replaces all topic names previously configured with a topic and additionally partitions and an offset to
* subscribe to
*
* @param string $topicName
* @param int[] $partitions
* @param integer $offset
* @return KafkaConsumerBuilderInterface
*/
public function withSubscription(
string $topicName,
array $partitions = [],
int $offset = self::OFFSET_STORED
): self;
/**
* Add configuration settings, otherwise the kafka defaults apply
*
* @param string[] $config
* @return KafkaConsumerBuilderInterface
*/
public function withAdditionalConfig(array $config): self;
/**
* Set the consumer group
*
* @param string $consumerGroup
* @return KafkaConsumerBuilderInterface
*/
public function withConsumerGroup(string $consumerGroup): self;
/**
* Set a callback to be called on errors.
* The default callback will throw an exception for every error
*
* @param callable $errorCallback
* @return KafkaConsumerBuilderInterface
*/
public function withErrorCallback(callable $errorCallback): self;
/**
* Set a callback to be called on consumer rebalance
*
* @param callable $rebalanceCallback
* @return KafkaConsumerBuilderInterface
*/
public function withRebalanceCallback(callable $rebalanceCallback): self;
/**
* Set callback that is being called on offset commits
*
* @param callable $offsetCommitCallback
* @return KafkaConsumerBuilderInterface
*/
public function withOffsetCommitCallback(callable $offsetCommitCallback): self;
/**
* Lets you set a custom decoder for the consumed message
*
* @param DecoderInterface $decoder
* @return KafkaConsumerBuilderInterface
*/
public function withDecoder(DecoderInterface $decoder): self;
/**
* Callback for log related events
*
* @param callable $logCallback
* @return KafkaConsumerBuilderInterface
*/
public function withLogCallback(callable $logCallback): self;
/**
* Set callback that is being called on offset commits
*
* @param callable $oauthBearerCallback
* @return KafkaConsumerBuilderInterface
*/
public function withOAuthBearerTokenRefreshCallback(callable $oauthBearerCallback): self;
/**
* Returns your consumer instance
*
* @return KafkaConsumerInterface
*/
public function build(): KafkaConsumerInterface;
}