-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from vtsykun/event-loop
Added ReactPHP EventLoop and standalone cron runner engine.
- Loading branch information
Showing
29 changed files
with
1,395 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
"dev-master": "1.1-dev" | ||
} | ||
}, | ||
"suggest": { | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Okvpn\Bundle\CronBundle\Attribute; | ||
|
||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
class AsPeriodicTask | ||
{ | ||
public $interval; | ||
public $lock; | ||
public $async; | ||
public $options; | ||
public $messenger; | ||
public $jitter; | ||
|
||
public function __construct( | ||
/*int|string */ $interval, | ||
bool $lock = null, | ||
bool $async = null, | ||
bool $messenger = null, | ||
int $jitter = null, | ||
array $options = [], | ||
) { | ||
$this->async = $async; | ||
$this->lock = $lock; | ||
$this->interval = $interval; | ||
$this->options = $options; | ||
$this->messenger = $messenger; | ||
$this->jitter = $jitter; | ||
} | ||
|
||
public function getAttributes(): array | ||
{ | ||
$attributes = get_object_vars($this); | ||
foreach ($attributes as $name => $value) { | ||
if (null === $value) { | ||
unset($attributes[$name]); | ||
} | ||
} | ||
|
||
$attributes = $attributes + $attributes['options']; | ||
unset($attributes['options']); | ||
|
||
return $attributes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Okvpn\Bundle\CronBundle\Clock; | ||
|
||
/** | ||
* Bridge for SF 4-5 support. Remove after update requires >= SF 6 | ||
* | ||
* @author Nicolas Grekas <[email protected]> | ||
*/ | ||
final class OkvpnLoopClock /*implements ClockInterface*/ | ||
{ | ||
private $timezone; | ||
|
||
public function __construct(/*\DateTimeZone|string */$timezone = null) | ||
{ | ||
if (\is_string($timezone = $timezone ?? \date_default_timezone_get())) { | ||
$this->timezone = new \DateTimeZone($timezone); | ||
} else { | ||
$this->timezone = $timezone; | ||
} | ||
} | ||
|
||
public function now(): \DateTimeImmutable | ||
{ | ||
return new \DateTimeImmutable('now', $this->timezone); | ||
} | ||
|
||
public function sleep($seconds): void | ||
{ | ||
if (0 < $s = (int) $seconds) { | ||
\sleep($s); | ||
} | ||
|
||
if (0 < $us = $seconds - $s) { | ||
\usleep((int) ($us * 1E6)); | ||
} | ||
} | ||
|
||
public function withTimeZone(/*\DateTimeZone|string*/ $timezone): static | ||
{ | ||
$clone = clone $this; | ||
$clone->timezone = \is_string($timezone) ? new \DateTimeZone($timezone) : $timezone; | ||
|
||
return $clone; | ||
} | ||
} |
Oops, something went wrong.