From 4dc9d1a481417bb78606996fa75c791bb646f44f Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 14 Dec 2024 16:26:30 +0000 Subject: job queue and workers and loggers! --- Digitigrade/Job/FetchObject.php | 25 +++++++++++++++++++++++++ Digitigrade/Job/UpdateInstanceInfo.php | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Digitigrade/Job/FetchObject.php create mode 100644 Digitigrade/Job/UpdateInstanceInfo.php (limited to 'Digitigrade/Job') diff --git a/Digitigrade/Job/FetchObject.php b/Digitigrade/Job/FetchObject.php new file mode 100644 index 0000000..227e05b --- /dev/null +++ b/Digitigrade/Job/FetchObject.php @@ -0,0 +1,25 @@ +type = $type; + $this->uri = $uri; + $this->remainingTries = 8; + } + + public function run() { + assert(is_subclass_of($this->type, FetchableModel::class)); + Logger::getInstance()->info("fetching $this->type at $this->uri"); + if ($this->type::findByUri($this->uri, forceRefetch: true) == null) { + throw new \RuntimeException("remote object doesn't seem to exist"); + } + } +} \ No newline at end of file diff --git a/Digitigrade/Job/UpdateInstanceInfo.php b/Digitigrade/Job/UpdateInstanceInfo.php new file mode 100644 index 0000000..85c11f0 --- /dev/null +++ b/Digitigrade/Job/UpdateInstanceInfo.php @@ -0,0 +1,22 @@ +domain = $domain; + $this->remainingTries = 3; + } + + public function run() { + Logger::getInstance()->info("updating info for instance $this->domain"); + if (Instance::findByDomain($this->domain, forceRefetch: true) == null) { + throw new \RuntimeException("remote object doesn't seem to exist"); + } + } +} \ No newline at end of file -- cgit v1.3