forked from yiisoft/queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove payloads, enhance docs (yiisoft#68)
Co-authored-by: Alexander Makarov <[email protected]>
- Loading branch information
1 parent
e05b43d
commit 0d5a7ac
Showing
46 changed files
with
847 additions
and
765 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
Yii Queue extension | ||
==================== | ||
# Yii Queue extension | ||
|
||
An extension for running tasks asynchronously via queues. | ||
|
||
Introduction | ||
------------ | ||
## Guides and concept explanations | ||
|
||
* [Usage basics](usage.md) | ||
* [Migrating from `yii2-queue`](migrating-from-yii2-queue.md) | ||
* [Message behaviors](behaviors.md) | ||
* [Errors and retryable jobs](retryable.md) | ||
* [Workers](worker.md) | ||
|
||
Queue Drivers | ||
------------- | ||
|
||
* [Synchronous](driver-sync.md) | ||
* [AMQP](https://github.com/yiisoft/yii-queue-amqp) | ||
* [Driver list](driver-list.md) |
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,42 @@ | ||
# Message behaviors | ||
|
||
`Behaviors` are classes designed to tell queue [drivers] about some specific message behavior: e.g. when you want | ||
to delay message consuming or set message priority. There are some predefined behaviors with which some | ||
default [drivers] can work. | ||
|
||
***Important!* Not every driver can work with all the behaviors. Below you will find a matrix displaying compatibility | ||
of drivers and behaviors.** | ||
|
||
## Default behaviors | ||
|
||
### DelayBehavior | ||
|
||
This behavior specifies amount of seconds the message can be consumed after. | ||
|
||
This code means the message can be consumed after 5 seconds since it was pushed to the queue server: | ||
|
||
```php | ||
$message->attachBehavior(new DelayBehavior(5)); | ||
``` | ||
|
||
### PriorityBehavior | ||
|
||
This behavior sets a relative order for message consuming. The higher the priority, the earlier a message will be consumed. | ||
|
||
Example: | ||
|
||
```php | ||
$message->attachBehavior(new PriorityBehavior(100)); | ||
``` | ||
|
||
## Compatibility matrix | ||
|
||
| | DelayBehavior | PriorityBehavior | ||
|---------------------|---------------------------|----------------- | ||
| [SynchronousDriver] | ❌ | ❌ | ||
| [Amqp] | yiisoft/yii-queue-amqp#11 | ❌ | ||
|
||
|
||
[drivers]: (driver-list.md) | ||
[SynchronousDriver]: (driver-sync.md) | ||
[Amqp]: (https://github.com/yiisoft/yii-queue-amqp) |
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,5 @@ | ||
Queue Drivers | ||
------------- | ||
|
||
* [Synchronous](driver-sync.md) - driver for development and test environments | ||
* [AMQP](https://github.com/yiisoft/yii-queue-amqp) - driver over AMQP protocol via [amqplib](https://github.com/php-amqplib/php-amqplib) |
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,33 @@ | ||
# Migrating from yii2-queue | ||
|
||
This package is similar to [yiisoft/yii2-queue] but with improved design and code style. The new package less coupled | ||
and more structured than the old one allowing better maintenance. | ||
|
||
## Drivers | ||
|
||
- Individual drivers are now separate packages. This means each driver must be `require`d with composer in order to | ||
be available in your application. | ||
- Driver may be any class which implements `DriverInterface`. This means you can replace one driver with another without | ||
changing any code in your app. For example, you can use `db` driver in development while using `amqp` in production, | ||
then you may seamlessly switch to `redis` if needed. This also means you can write your own driver implementation | ||
if necessary. | ||
|
||
## Jobs (Messages and Handlers) | ||
|
||
There was a concept in [yiisoft/yii2-queue] called `Job`: you had to push it to the queue, and it was executed after | ||
being consumed. In the new package it is divided into two different concepts: a message and a handler. | ||
|
||
- A `Message` is a class implementing `MessageInterface`. It contains 3 types of data: | ||
- Name. Worker uses it to find the right handler for a message. | ||
- Data. Any serializable data which should be used by the message handler. | ||
- Behaviors. Message behaviors used by drivers. For example, priority setting, message delaying, etc. [See more](behaviors.md). | ||
|
||
All the message data is fully serializable (that means message `data` must be serializable too). It allows you to | ||
freely choose where and how to send and process jobs. Both can be implemented in a single application, or | ||
separated into multiple applications, or you can do sending/processing only leaving part of the job to another | ||
system including non-PHP ones. It is fairly popular to process heavy jobs with Go. | ||
|
||
- A `Handler` is called by a `Worker` when a message comes. Default `Worker` finds a corresponding message handler | ||
by the message name. [See more](worker.md#handler-format). | ||
|
||
[yiisoft/yii2-queue]: (https://github.com/yiisoft/yii2-queue) |
Oops, something went wrong.