blob: f5f1430825edbda01a88f2d50689505296a15106 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
namespace Digitigrade\Job;
use Digitigrade\Job;
use Digitigrade\Logger;
use Digitigrade\Model\Instance;
use Digitigrade\Model\PushableModel;
class PushObject extends Job {
public string $objectType;
public string $objectId;
public string $recipientServerHost;
public function __construct(PushableModel $object, Instance $recipient) {
$this->objectType = $object::class;
$this->objectId = $object->id;
$this->recipientServerHost = $recipient->domain;
$this->remainingTries = 8;
}
public function run() {
$instance = Instance::findByHostname($this->recipientServerHost);
assert($instance != null);
$object = $this->objectType::find($this->objectId);
assert($object instanceof PushableModel);
Logger::getInstance()->info("pushing object $object->uri to server $instance->domain");
$instance->pushObject($object);
}
}
|