-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd378a6
commit 032c691
Showing
4 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Changelog | ||
|
||
All notable changes will be documented in this file. | ||
|
||
## 0.2.0 6/3/2020 | ||
|
||
### Added | ||
- Add `daemonize()` macro to `Event` | ||
|
||
### Changed | ||
|
||
### Fixed | ||
|
||
## 0.0.1 - 5/17/2020 | ||
- Initial release |
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,24 @@ | ||
<?php | ||
/** | ||
* @author Aaron Francis <[email protected]|https://twitter.com/aarondfrancis> | ||
*/ | ||
|
||
namespace Resolute\PseudoDaemon; | ||
|
||
use Illuminate\Console\Scheduling\CallbackEvent; | ||
use Illuminate\Console\Scheduling\Event; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class PseudoDaemonServiceProvider extends ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
Event::macro('daemonize', function () { | ||
if ($this instanceof CallbackEvent) { | ||
throw new \Exception('Cannot daemonize a CallbackEvent.'); | ||
} | ||
|
||
return $this->everyMinute()->runInBackground()->withoutOverlapping(); | ||
}); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
/** | ||
* @author Aaron Francis <[email protected]|https://twitter.com/aarondfrancis> | ||
*/ | ||
|
||
namespace Resolute\PseudoDaemon\Tests; | ||
|
||
use Illuminate\Console\Scheduling\CacheEventMutex; | ||
use Illuminate\Console\Scheduling\Event; | ||
use Orchestra\Testbench\TestCase; | ||
use Resolute\PseudoDaemon\PseudoDaemonServiceProvider; | ||
|
||
class EventDaemonizeTest extends TestCase | ||
{ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
PseudoDaemonServiceProvider::class | ||
]; | ||
} | ||
|
||
/** @test */ | ||
public function daemonize_macro_sets_appropriate_properties() | ||
{ | ||
$mutex = new CacheEventMutex(cache()); | ||
$event = (new Event($mutex, 'command'))->daemonize(); | ||
|
||
$this->assertTrue($event->runInBackground); | ||
$this->assertTrue($event->withoutOverlapping); | ||
$this->assertEquals('* * * * *', $event->expression); | ||
} | ||
} |