Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

UDP Client: Support writing large reports #9

Merged
merged 2 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions src/Jaeger/UDPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ public function emitBatch(Batch $batch)
$client = new AgentClient(null, $protocol);

$client->emitBatch($batch);
$data = $buffer->getBuffer();

try {
socket_sendto(
$socket,
$data,
strlen($data),
0,
$this->host,
$this->port
);
while ($buffer->available()) {
$data = $buffer->read(65507); // max size of DGRAM payload https://stackoverflow.com/a/38742429
socket_sendto(
$socket,
$data,
strlen($data),
( $buffer->available() ) ? MSG_EOR : MSG_EOF,
$this->host,
$this->port
);
}
} finally {
socket_close($socket);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Jaeger/UDPClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testUsesSockets()
$resource,
Argument::type('string'),
Argument::type('int'),
0,
512,
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
'1.1.1.1',
1234
)->willReturn(123)->shouldBeCalledTimes(1);
Expand Down