-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeKeeperInterface.php
36 lines (32 loc) · 1.11 KB
/
TimeKeeperInterface.php
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
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace Issei\SimpleJobSchedule;
/**
* The time-keeper for schedule, keeps the time when the job was last run (i.e. enqueued).
*
* @author Issei Murasawa <issei.m7@gmail.com>
*/
interface TimeKeeperInterface
{
/**
* Returns the time when the job was last run.
* It returns a NULL if the job has never yet been run (at first time to be enlisted to the schedule set).
*
* @param string $key
*
* @return \DateTimeInterface|null
*/
public function getLastRanTime(string $key): ?\DateTimeInterface;
/**
* Returns true if it succeeded to save the time when the job last run, otherwise false.
*
* On multiple schedulers make sure the only one works to save and returns true, while other one should not to do and return false,
* meaning some locking structure may be needed to address conflict between multiple scheduler.
*
* @param string $key
* @param \DateTimeInterface $runTime
*
* @return bool
*/
public function attemptToKeepRunTime(string $key, \DateTimeInterface $runTime): bool;
}