Skip to content
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
5 changes: 2 additions & 3 deletions lib/Consumer/ForkCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ public function flushBatch($messages)

$cmd .= " '" . $url . "'";

// Verify message size is below than 32KB
if (strlen($payload) >= 32 * 1024) {
if (strlen($payload) >= self::MAX_BATCH_PAYLOAD_SIZE) {
if ($this->debug()) {
$msg = "Message size is larger than 32KB";
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
error_log("[PostHog][" . $this->type . "] " . $msg);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/Consumer/LibCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ public function flushBatch($messages)
$body = $this->payload($messages);
$payload = json_encode($body);

// Verify message size is below than 32KB
if (strlen($payload) >= 32 * 1024) {
if (strlen($payload) >= self::MAX_BATCH_PAYLOAD_SIZE) {
if ($this->debug()) {
$msg = "Message size is larger than 32KB";
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
error_log("[PostHog][" . $this->type . "] " . $msg);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/Consumer/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ private function createBody($host, $content)
$req .= "\r\n";
$req .= $content;

// Verify message size is below than 32KB
if (strlen($req) >= 32 * 1024) {
if (strlen($req) >= self::MAX_BATCH_PAYLOAD_SIZE) {
if ($this->debug()) {
$msg = "Message size is larger than 32KB";
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
error_log("[PostHog][" . $this->type . "] " . $msg);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

abstract class QueueConsumer extends Consumer
{
protected const MAX_BATCH_PAYLOAD_SIZE = 1024 * 1024; // 1MB
protected const MAX_BATCH_PAYLOAD_SIZE_HUMAN = (self::MAX_BATCH_PAYLOAD_SIZE / 1024) . 'KB';

protected $type = "QueueConsumer";

protected $queue;
Expand Down
Loading