This commit is contained in:
shimon
2022-12-04 19:06:23 +02:00
parent d3bc4da15c
commit b71bba2a9c
10 changed files with 142 additions and 63 deletions
+3
View File
@@ -23,6 +23,9 @@ class Event
public const FUNCTIONS_QUEUE_NAME = 'v1-functions';
public const FUNCTIONS_CLASS_NAME = 'FunctionsV1';
public const USAGE_QUEUE_NAME = 'v1-usage';
public const USAGE_CLASS_NAME = 'UsageV1';
public const WEBHOOK_QUEUE_NAME = 'v1-webhooks';
public const WEBHOOK_CLASS_NAME = 'WebhooksV1';
+4 -8
View File
@@ -11,11 +11,11 @@ class Usage extends Event
public function __construct(protected Connection $connection)
{
parent::__construct(Event::FUNCTIONS_QUEUE_NAME, Event::FUNCTIONS_CLASS_NAME);
parent::__construct(Event::USAGE_QUEUE_NAME, Event::USAGE_CLASS_NAME);
}
/**
* Sets function document for the function event.
* Add metric.
*
* @param string $namespace
* @param string $key
@@ -34,19 +34,15 @@ class Usage extends Event
}
/**
* Executes the function event and sends it to the functions worker.
* Sends metrics to the usage worker.
*
* @return bool
* @return string|bool
*/
public function trigger(): string|bool
{
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'project' => $this->project,
'user' => $this->user,
'type' => $this->type,
'payload' => $this->payload,
'metrics' => $this->metrics,
]);
}