KMP PHP API Reference

EmailTask extends Task
in package
implements AddInterface, AddFromBackendInterface

A convenience task ready to use for asynchronously sending basic emails.

Uses basic Message object.

Especially useful is the fact that sending is auto-retried as per your config. Will not drop the email if successfully sent, you can decide to even retry manually again afterwards.

Tags
author

Mark Scherer

license

http://www.opensource.org/licenses/mit-license.php The MIT License

Table of Contents

Interfaces

AddInterface
Any task needs to at least implement add().
AddFromBackendInterface
Any task that does not need arguments and can be added from backend GUI.

Properties

$costs  : int
Activate this if you want cost management per server to avoid server overloading.
$mailer  : Mailer
$message  : Message
$QueuedJobs  : QueuedJobsTable
$queueModelClass  : string
$rate  : int
Rate limiting per worker in seconds.
$retries  : int|null
Number of times a failed instance of this task should be restarted before giving up.
$timeout  : int|null
Timeout in seconds, after which the Task is reassigned to a new worker if not finished successfully.
$unique  : bool
Set to true if you want to make sure this specific task is never run in parallel, neither on the same server, nor any other server. Any worker running will not fetch this task, if any job here is already in progress.
$defaults  : array<string, mixed>
List of default variables for Email class.
$io  : Io
$logger  : LoggerInterface|null

Methods

__construct()  : mixed
add()  : void
"Add" the task, not possible for EmailTask without adminEmail configured.
run()  : void
Main execution of the task.
serialize()  : array<string|int, mixed>
taskName()  : string
unserialize()  : Message
getMailer()  : Mailer
Check if Mail class exists and create instance

Properties

$costs

Activate this if you want cost management per server to avoid server overloading.

public int $costs = 0

Expensive tasks (CPU, memory, ...) can have 1...100 points here, with higher points preventing a similar cost intensive task to be fetched on the same server in parallel. Smaller ones can easily still be processed on the same server if some an expensive one is running.

$queueModelClass

public string $queueModelClass = 'Queue.QueuedJobs'

$rate

Rate limiting per worker in seconds.

public int $rate = 0

Activate this if you want to stretch the processing of a specific task per worker.

$retries

Number of times a failed instance of this task should be restarted before giving up.

public int|null $retries = null

Defaults to Config::defaultworkerretries().

$timeout

Timeout in seconds, after which the Task is reassigned to a new worker if not finished successfully.

public int|null $timeout = 60

This should be high enough that it cannot still be running on a zombie worker (>> 2x). Defaults to Config::defaultworkertimeout().

$unique

Set to true if you want to make sure this specific task is never run in parallel, neither on the same server, nor any other server. Any worker running will not fetch this task, if any job here is already in progress.

public bool $unique = false

$defaults

List of default variables for Email class.

protected array<string, mixed> $defaults = []

$logger

protected LoggerInterface|null $logger = null

Methods

__construct()

public __construct([Io|null $io = null ][, LoggerInterface|null $logger = null ]) : mixed
Parameters
$io : Io|null = null

IO

$logger : LoggerInterface|null = null

add()

"Add" the task, not possible for EmailTask without adminEmail configured.

public add(string|null $data) : void
Parameters
$data : string|null

run()

Main execution of the task.

public run(array<string, mixed> $data, int $jobId) : void
Parameters
$data : array<string, mixed>

The array passed to QueuedJobsTable::createJob()

$jobId : int

The id of the QueuedJob entity

Tags
throws
QueueException
throws
Throwable

serialize()

public static serialize(Message $message) : array<string|int, mixed>
Parameters
$message : Message
Return values
array<string|int, mixed>

taskName()

public static taskName() : string
Tags
throws
InvalidArgumentException
Return values
string

unserialize()

public static unserialize(Message $object, array<string|int, mixed> $config) : Message
Parameters
$object : Message
$config : array<string|int, mixed>
Return values
Message

getMailer()

Check if Mail class exists and create instance

protected getMailer() : Mailer
Tags
throws
QueueException
Return values
Mailer

        
On this page

Search results