Skip to content

Commit

Permalink
ProcessJobExecutor: uses microseconds instead of milliseconds for sta…
Browse files Browse the repository at this point in the history
…rt and end times
  • Loading branch information
mabar committed Dec 11, 2023
1 parent 7e8f2e5 commit 2f0d896
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `runJobs()` returns `Generator<int, JobSummary, void, RunSummary>` instead of `RunSummary`
- `ProcessJobExecutor`
- constructor requires `JobManager` as first parameter
- uses microseconds instead of milliseconds for start and end times
- `ManagedScheduler`
- acquired job locks are scoped just to their id - changing run frequency or job name will not make process loose
the lock
4 changes: 2 additions & 2 deletions src/Executor/ProcessJobExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ private function createSummary(array $raw): JobSummary
$raw['info']['name'],
$raw['info']['expression'],
$raw['info']['second'],
DateTimeImmutable::createFromFormat('U.v', $raw['info']['start']),
DateTimeImmutable::createFromFormat('U.u', $raw['info']['start']),
),
new JobResult(
new CronExpression($raw['info']['expression']),
DateTimeImmutable::createFromFormat('U.v', $raw['result']['end']),
DateTimeImmutable::createFromFormat('U.u', $raw['result']['end']),
JobResultState::from($raw['result']['state']),
),
);
Expand Down
2 changes: 1 addition & 1 deletion src/Status/JobInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function toArray(): array
'name' => $this->getName(),
'expression' => $this->getExpression(),
'second' => $this->getSecond(),
'start' => $this->getStart()->format('U.v'),
'start' => $this->getStart()->format('U.u'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Status/JobResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getNextRunDates(int $total): array
public function toArray(): array
{
return [
'end' => $this->getEnd()->format('U.v'),
'end' => $this->getEnd()->format('U.u'),
'state' => $this->getState()->value,
];
}
Expand Down
16 changes: 8 additions & 8 deletions tests/Unit/Command/RunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public function testSuccess(): void
"name": "Tests\\Orisai\\Scheduler\\Doubles\\CallbackList::job1()",
"expression": "* * * * *",
"second": 0,
"start": "1.000"
"start": "1.000000"
},
"result": {
"end": "1.000",
"end": "1.000000",
"state": "done"
}
},
Expand All @@ -118,10 +118,10 @@ public function testSuccess(): void
"name": "Tests\\Orisai\\Scheduler\\Doubles\\CallbackList::job2()",
"expression": "* * * * *",
"second": 0,
"start": "1.000"
"start": "1.000000"
},
"result": {
"end": "1.000",
"end": "1.000000",
"state": "done"
}
}
Expand Down Expand Up @@ -179,10 +179,10 @@ public function testFailure(): void
"name": "Tests\\Orisai\\Scheduler\\Doubles\\CallbackList::job1()",
"expression": "* * * * *",
"second": 0,
"start": "1.000"
"start": "1.000000"
},
"result": {
"end": "1.000",
"end": "1.000000",
"state": "done"
}
},
Expand All @@ -192,10 +192,10 @@ public function testFailure(): void
"name": "Tests\\Orisai\\Scheduler\\Doubles\\CallbackList::exceptionJob()",
"expression": "* * * * *",
"second": 0,
"start": "1.000"
"start": "1.000000"
},
"result": {
"end": "1.000",
"end": "1.000000",
"state": "fail"
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Command/RunJobCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ public function testJson(): void
"name": "Tests\\Orisai\\Scheduler\\Doubles\\CallbackList::job1()",
"expression": "1 * * * *",
"second": 30,
"start": "61.000"
"start": "61.000000"
},
"result": {
"end": "61.000",
"end": "61.000000",
"state": "done"
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Status/JobInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function test(): void
'name' => $name,
'expression' => $expression,
'second' => $second,
'start' => $start->format('U.v'),
'start' => $start->format('U.u'),
],
$info->toArray(),
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Status/JobResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test(): void

self::assertSame(
[
'end' => $end->format('U.v'),
'end' => $end->format('U.u'),
'state' => JobResultState::done()->value,
],
$result->toArray(),
Expand Down

0 comments on commit 2f0d896

Please sign in to comment.