mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
Merge branch '1.8.x' into chore-upgrade-cache
This commit is contained in:
commit
ca464f8a71
2 changed files with 29 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ class Event
|
|||
|
||||
public const FUNCTIONS_QUEUE_NAME = 'v1-functions';
|
||||
public const FUNCTIONS_CLASS_NAME = 'FunctionsV1';
|
||||
public const FUNCTIONS_QUEUE_TTL = 60 * 60 * 24 * 7; // 7 days
|
||||
|
||||
public const STATS_RESOURCES_QUEUE_NAME = 'v1-stats-resources';
|
||||
public const STATS_RESOURCES_CLASS_NAME = 'StatsResourcesV1';
|
||||
|
|
@ -65,6 +66,8 @@ class Event
|
|||
/** @var bool Non-critical events will not throw an exception when enqueuing of the event fails. */
|
||||
protected bool $critical = true;
|
||||
|
||||
protected int $ttl = 0;
|
||||
|
||||
/**
|
||||
* @param Publisher $publisher
|
||||
* @return void
|
||||
|
|
@ -114,6 +117,29 @@ class Event
|
|||
return $this->queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TTL (time-to-live) for jobs in this queue.
|
||||
*
|
||||
* @param int $ttl TTL in seconds
|
||||
* @return static
|
||||
*/
|
||||
public function setTTL(int $ttl): static
|
||||
{
|
||||
$this->ttl = $ttl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TTL (time-to-live) for jobs in this queue.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTTL(): int
|
||||
{
|
||||
return $this->ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set event name used for this event.
|
||||
* @param string $event
|
||||
|
|
@ -369,7 +395,7 @@ class Event
|
|||
}
|
||||
|
||||
/** The getter is required since events like Databases need to override the queue name depending on the project */
|
||||
$queue = new Queue($this->getQueue());
|
||||
$queue = new Queue($this->getQueue(), 'utopia-queue', $this->getTTL());
|
||||
|
||||
// Merge the base payload with any trimmed values
|
||||
$payload = array_merge($this->preparePayload(), $this->trimPayload());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class Func extends Event
|
|||
|
||||
$this
|
||||
->setQueue(System::getEnv('_APP_FUNCTIONS_QUEUE_NAME', Event::FUNCTIONS_QUEUE_NAME))
|
||||
->setClass(System::getEnv('_APP_FUNCTIONS_CLASS_NAME', Event::FUNCTIONS_CLASS_NAME));
|
||||
->setClass(System::getEnv('_APP_FUNCTIONS_CLASS_NAME', Event::FUNCTIONS_CLASS_NAME))
|
||||
->setTTL(Event::FUNCTIONS_QUEUE_TTL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue