Skip to content

Repository files navigation

sentry-cron

LicenseLatest VersionTotal Downloadsphp 8.2+

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.

composer require fusonic/sentry-cron

Configuration

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:

useFusonic\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:

useFusonic\SentryCron\SentryMonitorConfig;
useFusonic\SentryCron\AsyncCheckInScheduleEventInterface;
use \Fusonic\SentryCron\AsyncCheckInScheduleEventTrait;
class SomeEvent implements AsyncCheckInScheduleEventInterface {
use AsyncCheckInScheduleEventTrait;
// ...
}

The manual check in:

class SomeEventHandler {
privateconstBATCH_SIZE = 100;
publicfunction__invoke(SomeEvent$event): void {
$offset = 0;
// e.g.: some slow database processing$entitiesToProcess = // ...$nextEvent = newSomeEvent(offset: $offset + self::BATCH_SIZE);
if (count($entitiesToProcess) === 0) {
$nextEvent->markAsLast();
}
$this->eventBus->dispatch($nextEvent);
}
}

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages