Skip to content

v2.7.0-BETA3

Pre-release
Pre-release
Compare
Choose a tag to compare
@roxblnfk roxblnfk released this 30 Nov 12:04
· 221 commits to master since this release
6504057

What's Changed

Schedule API

Concept
Temporal Schedules: Reliable, Scalable, and More Flexible than Cron Jobs (blog post)

Example

use Temporal\Client\Schedule;

// Create a Schedule Client
$client = \Temporal\Client\ScheduleClient::create(
    \Temporal\Client\GRPC\ServiceClient::create('localhost:7233'),
);

// Create a Schedule
$handle = $client->createSchedule(
    Schedule\Schedule::new()->withAction(
        Schedule\Action\StartWorkflowAction::new('testWorkflow')
            ->withTaskQueue('testTaskQueue')
            ->withRetryPolicy(\Temporal\Common\RetryOptions::new()->withMaximumAttempts(3))
            ->withHeader(['foo' => 'bar'])
            ->withWorkflowExecutionTimeout('40m')
    )->withSpec(
        Schedule\Spec\ScheduleSpec::new()
            ->withCronStringList('0 * * * *')
    ),
    scheduleId: 'testSchedule',
);

// Describe the Schedule
$description = $handle->describe();


// Update the Schedule
$handle->update(
    $description->schedule->withSpec(
        Schedule\Spec\ScheduleSpec::new()
            ->withCronStringList('0 12 * * 5', '0 12 * * 1')
    ),
    conflictToken: $description->conflictToken, // To avoid race condition
);

// Pause the Schedule
$handle->pause();

// Trigger the Action to be taken immediately
$handle->trigger(Schedule\Policy\ScheduleOverlapPolicy::CancelOther);

// Delete the Schedule
$handle->delete();

Full Changelog: v2.7.0-BETA2...v2.7.0-BETA3