-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKafkaProducerInterface.php
113 lines (100 loc) · 3.21 KB
/
KafkaProducerInterface.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
<?php
namespace PhpKafka\Producer;
use PhpKafka\Exception\KafkaProducerTransactionAbortException;
use PhpKafka\Exception\KafkaProducerTransactionFatalException;
use PhpKafka\Exception\KafkaProducerTransactionRetryException;
use PhpKafka\Message\KafkaProducerMessageInterface;
use SimpleKafkaClient\Metadata\Topic as SkcMetadataTopic;
interface KafkaProducerInterface
{
/**
* @param KafkaProducerMessageInterface $message
* @param boolean $autoPoll
* @param integer $pollTimeoutMs
* @return void
*/
public function produce(
KafkaProducerMessageInterface $message,
bool $autoPoll = true,
int $pollTimeoutMs = 0
): void;
/**
* Produces a message to the topic and partition defined in the message
* If a schema name was given, the message body will be avro serialized.
* Wait for the message to event to arrive before continuing (blocking)
*
* @param KafkaProducerMessageInterface $message
* @return void
*/
public function syncProduce(KafkaProducerMessageInterface $message): void;
/**
* Poll for producer event, pass 0 for non-blocking, pass -1 to block until an event arrives
*
* @param integer $timeoutMs
* @return void
*/
public function poll(int $timeoutMs = 0): void;
/**
* Poll for producer events until the number of $queueSize events remain
*
* @param integer $timeoutMs
* @param integer $queueSize
* @return void
*/
public function pollUntilQueueSizeReached(int $timeoutMs = 0, int $queueSize = 0): void;
/**
* Purge producer messages that are in flight
*
* @param integer $purgeFlags
* @return integer
*/
public function purge(int $purgeFlags): int;
/**
* Wait until all outstanding produce requests are completed
*
* @param integer $timeoutMs
* @return integer
*/
public function flush(int $timeoutMs): int;
/**
* Queries the broker for metadata on a certain topic
*
* @param string $topicName
* @param integer $timeoutMs
* @return SkcMetadataTopic
*/
public function getMetadataForTopic(string $topicName, int $timeoutMs = 10000): SkcMetadataTopic;
/**
* Start a producer transaction
*
* @param int $timeoutMs
* @return void
*
* @throws KafkaProducerTransactionAbortException
* @throws KafkaProducerTransactionFatalException
* @throws KafkaProducerTransactionRetryException
*/
public function beginTransaction(int $timeoutMs): void;
/**
* Commit the current producer transaction
*
* @param int $timeoutMs
* @return void
*
* @throws KafkaProducerTransactionAbortException
* @throws KafkaProducerTransactionFatalException
* @throws KafkaProducerTransactionRetryException
*/
public function commitTransaction(int $timeoutMs): void;
/**
* Abort the current producer transaction
*
* @param int $timeoutMs
* @return void
*
* @throws KafkaProducerTransactionAbortException
* @throws KafkaProducerTransactionFatalException
* @throws KafkaProducerTransactionRetryException
*/
public function abortTransaction(int $timeoutMs): void;
}