https://github.com/fusonic/php-sentry-cron
https://github.com/fusonic/php-sentry-cron
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fusonic/php-sentry-cron
- Owner: fusonic
- License: mit
- Created: 2025-07-14T07:03:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-04T08:47:00.000Z (8 months ago)
- Last Synced: 2025-12-26T16:48:24.702Z (7 months ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sentry-cron
[](https://github.com/fusonic/php-sentry-cron/blob/master/LICENSE)
[](https://github.com/fusonic/php-sentry-cron/releases)
[](https://packagist.org/packages/fusonic/sentry-cron)
[](https://github.com/fusonic/php-sentry-cron/blob/master/composer.json)
* [About](#about)
* [Install](#install)
* [Usage](#usage)
## About
Automatically register scheduled events from Symfony Scheduler in Sentry Cron. Only cron expressions are supported.
## Install
Use composer to install the library from packagist.
```bash
composer require fusonic/sentry-cron
```
## Configuration
```yaml
Fusonic\SentryCron\SentrySchedulerEventSubscriber:
arguments:
$enabled: true
```
## Usage
Any regular event that is triggered with a cron expression can be used.
### Event Configuration
By default, the Sentry defaults are used for monitor configurations. Per event, you can configure
an attribute to use your own configuration:
```php
use Fusonic\SentryCron\SentryMonitorConfig;
#[SentryMonitorConfig(checkinMargin: 30, maxRuntime: 30, failureIssueThreshold: 5, recoveryThreshold: 5)]
class SomeEvent {
// ...
}
```
### Async Events
If you have an unpredictable longer-running scheduled task, you can manually check in by implementing `AsyncCheckInScheduleEventInterface`.
The scheduled event:
```php
use Fusonic\SentryCron\SentryMonitorConfig;
use Fusonic\SentryCron\AsyncCheckInScheduleEventInterface;
use \Fusonic\SentryCron\AsyncCheckInScheduleEventTrait;
class SomeEvent implements AsyncCheckInScheduleEventInterface {
use AsyncCheckInScheduleEventTrait;
// ...
}
```
The manual check in:
```php
class SomeEventHandler {
private const BATCH_SIZE = 100;
public function __invoke(SomeEvent $event): void {
$offset = 0;
// e.g.: some slow database processing
$entitiesToProcess = // ...
$nextEvent = new SomeEvent(offset: $offset + self::BATCH_SIZE);
if (count($entitiesToProcess) === 0) {
$nextEvent->markAsLast();
}
$this->eventBus->dispatch($nextEvent);
}
}
```