diff options
| author | winter | 2024-12-14 16:26:30 +0000 |
|---|---|---|
| committer | winter | 2024-12-14 16:26:30 +0000 |
| commit | 4dc9d1a481417bb78606996fa75c791bb646f44f (patch) | |
| tree | 1e5c1beff234999a0a0eb9819515644ec73d965d /Digitigrade/Job/FetchObject.php | |
| parent | 86cf52e8d2701e13bd9fd4c847b35eba7506c473 (diff) | |
job queue and workers and loggers!
Diffstat (limited to 'Digitigrade/Job/FetchObject.php')
| -rw-r--r-- | Digitigrade/Job/FetchObject.php | 25 |
1 files changed, 25 insertions, 0 deletions
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 @@ +<?php +namespace Digitigrade\Job; + +use Digitigrade\Job; +use Digitigrade\Logger; +use Digitigrade\Model\FetchableModel; + +class FetchObject extends Job { + public string $uri; + public string $type; + + public function __construct(string $type, string $uri) { + $this->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 |
