-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaeron_stub.php
175 lines (158 loc) · 4 KB
/
aeron_stub.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
namespace Aeron;
use Exception;
class AeronException extends Exception
{
}
/**
* An error has occurred. Such as a bad argument.
*/
class AeronPublicationException extends AeronException
{
}
/**
* The publication is not connected to a subscriber, this can be an intermittent state as subscribers come and go.
*/
class AeronPublicationNotConnectedException extends AeronPublicationException
{
}
/**
* The offer failed due to back pressure from the subscribers preventing further transmission.
*/
class AeronPublicationBackPressuredException extends AeronPublicationException
{
}
/**
* The offer failed due to an administration action and should be retried.
* The action is an operation such as log rotation which is likely to have succeeded by the next retry attempt.
*/
class AeronPublicationAdminActionException extends AeronPublicationException
{
}
/**
* The publication has been closed and should no longer be used.
*/
class AeronPublicationClosedException extends AeronPublicationException
{
}
/**
* The offer failed due to reaching the maximum position of the stream given term buffer length times the total possible
* number of terms.
*
* If this happens then the publication should be closed and a new one added. To make it less likely to happen then
* increase the term buffer length.
*/
class AeronPublicationMaxPositionExceededException extends AeronPublicationException
{
}
/**
* A simple publisher that sends messages
*/
class Publisher
{
/**
* @param string $channel uri for the channel of the publication.
* @param int $stream_id for the publication.
*
* @throws AeronException
*/
public function __construct(
string $channel = "aeron:udp?endpoint=localhost:20121",
int $stream_id = 1001,
)
{
}
/**
* Publish the message.
*
* @param string $message to publish.
*
* @return int the new stream position.
*
* @throws AeronPublicationAdminActionException
* @throws AeronPublicationClosedException
* @throws AeronPublicationMaxPositionExceededException
* @throws AeronPublicationNotConnectedException
* @throws AeronPublicationBackPressuredException
*/
public function offer(string $message): int
{
}
/**
* Close the publication.
*
* @return void
*
* @throws AeronException
*/
public function close(): void
{
}
}
/**
* A simple subscriber that receives messages
*/
class Subscriber
{
/**
* @param callable $handler for handling each message.
* @param string $channel for the channel of the subscription.
* @param int $stream_id for the subscription.
*
* @throws AeronException
*/
public function __construct(
callable $handler,
string $channel = "aeron:udp?endpoint=localhost:20121",
int $stream_id = 1001,
)
{
}
/**
* Add a destination manually to a multi-destination-subscription.
*
* @param string $channel uri for the destination to add.
*
* @return void
*
* @throws AeronException
*/
public function addDestination(string $channel): void
{
}
/**
* Remove a destination manually from a multi-destination-subscription.
*
* @param string $channel uri for the destination to remove.
*
* @return void
*
* @throws AeronException
*/
public function removeDestination(string $channel): void
{
}
/**
* Poll the images under the subscription for available message fragments.
*
* Each fragment read will be a whole message if it is under MTU length.
* If larger than MTU then it will come as a series of fragments ordered within a session.
*
* @return int the number of fragments received
*
* @throws AeronException
*/
public function poll(): int
{
}
/**
* Close the subscription.
*
* @return void
*
* @throws AeronException
*/
public function close(): void
{
}
}