| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| */ | ||
| private function getFileName($key) | ||
| { | ||
| return $this->lockPath . DIRECTORY_SEPARATOR . preg_replace('/[^a-zA-Z]/', '_', $key) . '.lock'; |
There was a problem hiding this comment.
0-9
Sorry, something went wrong.
| function (TaskExecutionInterface $execution) use ($task) { | ||
| return $execution->getTask()->getUuid() === $task->getUuid() | ||
| && in_array($execution->getStatus(), [TaskStatus::PLANNED, TaskStatus::RUNNING]); | ||
| && in_array($execution->getStatus(), [TaskStatus::PLANNED, TaskStatus::RUNNING]); |
There was a problem hiding this comment.
check styleci config
Sorry, something went wrong.
| * Will be thrown when a conflict is detected: | ||
| * + Already acquired key was acquired. | ||
| * + Not acquired key was released. | ||
| * + Not acquired key was refreshed. |
There was a problem hiding this comment.
Can't you throw more specific exception instead of one for all cases? This way it will be harder to debug as it have to (You can't directly see from the exception if the key was already acquired or not).
Sorry, something went wrong.
| /** | ||
| * Save locks in the filesystem. | ||
| */ | ||
| class FileLock implements StorageInterface |
There was a problem hiding this comment.
FileLockStorage?
Sorry, something went wrong.
| /** | ||
| * Interface for lock storage. | ||
| */ | ||
| interface StorageInterface |
There was a problem hiding this comment.
LockStorageInterface?
Sorry, something went wrong.
| * @param mixed $result | ||
| * | ||
| * @return TaskExecutionInterface | ||
| */ |
There was a problem hiding this comment.
Methods should be named like verbs.
Sorry, something went wrong.
| * @param \Exception $exception | ||
| * | ||
| * @return TaskExecutionInterface | ||
| */ |
There was a problem hiding this comment.
Methods should be named like verbs.
Sorry, something went wrong.
| * @return TaskExecutionInterface | ||
| */ | ||
| public function findScheduled(); | ||
| public function findNextScheduled(\DateTime $dateTime = null); |
There was a problem hiding this comment.
BC break?
Sorry, something went wrong.
There was a problem hiding this comment.
of course (: I will add an upgrade. This interface is only used for internal usage (TaskRunner) so it should only be important for developers.
Sorry, something went wrong.
| new TaskExecutionEvent($execution->getTask(), $execution) | ||
| ); | ||
| $runTime = new \DateTime(); | ||
|
|
There was a problem hiding this comment.
Is performance a concern here? You are multiplying the database requests this way. Can't you still load all of them at once and keep them in memory before executing them?
Sorry, something went wrong.
There was a problem hiding this comment.
No here is the performance not so important. More important is that the execution is always clean and sync with the database. as you see the implementation before has loaded the whole execution which has to be executed. But in the loop, it was always refreshed because the task could reset (or the listener in the bundle) doctrine. So I change it to this more explicit implementation.
Sorry, something went wrong.
There was a problem hiding this comment.
The rest looks good, but I don't have anything to test, and setting that up is probably quite some work... Can maybe @alexander-schranz test again?
Sorry, something went wrong.
| */ | ||
| class LockAlreadyAcquiredException extends LockConflictException | ||
| { | ||
| } |
There was a problem hiding this comment.
Wouldn't you also add a nice error message here?
Sorry, something went wrong.
| */ | ||
| class LockNotAcquiredException extends LockConflictException | ||
| { | ||
| } |
There was a problem hiding this comment.
Same as above, wouldn't a message be nice?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR introduces a simple lock mechanism which blocks all the executions for the related handler when the execution runs.
Docs php-task/docs#5