File tree

10 files changed

+250
-135
lines changed

10 files changed

+250
-135
lines changed
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
# List of patterns, relative to source directory, that match files and
7676
# directories to ignore when looking for source files.
77-
exclude_patterns = ['_build']
77+
exclude_patterns = ['_build', 'demo']
7878

7979
# The reST default role (used for this markup: `text`) to use for all
8080
# documents.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
include __DIR__ . '/vendor/autoload.php';
44

5-
class ImageResizeHandler implements Task\Handler\HandlerInterface
5+
class ImageResizeHandler implements Task\Handler\TaskHandlerInterface
66
{
77
/**
88
* {@inheritdoc}
@@ -32,27 +32,30 @@ public function handle($workload)
3232
}
3333
}
3434

35-
// bootstrap
36-
$storage = new Task\Storage\ArrayStorage();
37-
$registry = new Task\Handler\Registry();
38-
$taskBuilderFactory = new Task\TaskBuilderFactory();
35+
// storage
36+
$taskRepository = new Task\Storage\ArrayStorage\ArrayTaskRepository();
37+
$taskExecutionRepository = new Task\Storage\ArrayStorage\ArrayTaskExecutionRepository();
38+
39+
// utility
3940
$eventDiser = new Symfony\Component\EventDiser\EventDiser();
40-
$scheduler = new Task\Scheduler($storage, $registry, $taskBuilderFactory, $eventDiser);
41+
$taskHandlerFactory = new Task\Handler\TaskHandlerFactory();
42+
$factory = new Task\Builder\TaskBuilderFactory();
4143

42-
// register handler
43-
$registry->add('app.image_resize', new ImageResizeHandler());
44+
// core components
45+
$scheduler = new Task\Scheduler\TaskScheduler($factory, $taskRepository, $taskExecutionRepository, $eventDiser);
46+
$runner = new Task\Runner\TaskRunner($taskExecutionRepository, $taskHandlerFactory, $eventDiser);
4447

4548
// schedule task one
4649
$scheduler->createTask(
47-
'app.image_resize',
50+
ImageResizeHandler::class,
4851
[__DIR__ . '/images/example-1.jpg', __DIR__ . '/images/thumbnails/example-1.jpg', 100]
4952
)->schedule();
5053

5154
// scheduel task twos
5255
$scheduler->createTask(
53-
'app.image_resize',
56+
ImageResizeHandler::class,
5457
[__DIR__ . '/images/example-2.jpg', __DIR__ . '/images/thumbnails/example-2.jpg', 100]
5558
)->schedule();
5659

5760
// run tasks
58-
$scheduler->run();
61+
$runner->runTasks();
This file was deleted.
This file was deleted.
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ Welcome to php-task's documentation!
44
This is the documentation for the php-task library.
55

66
Contents:
7+
---------
78

89
.. toctree::
910
:maxdepth: 2
1011

1112
introduction
12-
implementations
1313
symfony
14-
api
1514

1615
Indices and tables
1716
==================
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ What it does
88
It allows to implement handler classes in PHP for tasks. These handler
99
can be implemented in your favorite environment. Over a simple
1010
interface the developer can define and schedule long running tasks
11-
without any overhead.
11+
without any overhead for the user of the application.
1212

13-
One typical usecase is generating thumbnails or rendering videos.
14-
These tasks are to long to run them immediately and can be done after
15-
generating the response to the user.
13+
One typical usecase is generating thumbnails, rendering videos or
14+
update statistics of big data amount. These tasks are to long to run
15+
them immediately and can be done after sending the response to the
16+
user.
1617

1718
Quick Example
1819
-------------
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@ Features
77
Additional features which are implemented in this bundle.
88

99
* Handler discovery
10-
* Automatic registration of frequent tasks
1110
* Different run possibilities
11+
* Different commands to manage and debug commands
12+
* Persist tasks and executions in database
13+
* Run statistics foreach execution of tasks
1214

1315
Installation
1416
------------
1517

1618
.. code-block:: bash
1719
18-
composer require php-task/TaskBundle 1.0-x@dev
20+
composer require php-task/task-bundle 1.0.x-dev
1921
2022
Usage
2123
-----
2224
There are currently two ways to run tasks.
2325

24-
kernel.terminate
25-
^^^^^^^^^^^^^^^^
26-
The tasks will automatically executed when symfony fire this event
27-
which will be fired when the response is sen to the browser.
26+
Event: kernel.terminate
27+
^^^^^^^^^^^^^^^^^^^^^^^
28+
The tasks will automatically executed after sending the response.
2829

2930
.. note::
3031

@@ -38,22 +39,27 @@ which will be fired when the response is sen to the browser.
3839
Command
3940
^^^^^^^
4041
The bundle provides a command to run all taks which are scheduled before
41-
run time. This command can be called by a cronjob which enables frequent
42+
run time. This command can be called by a cronjob which enables recurring
4243
tasks.
4344

4445
.. code-block:: bash
4546
4647
app/console task:run
4748
49+
.. note::
50+
51+
This option only works if you enable the storage in doctrine which will
52+
persist your tasks in a table-structure.
53+
4854
Configuration Reference
4955
-----------------------
5056

5157
.. code-block:: yaml
5258
5359
task:
54-
storage: array # One of "array"; "doctrine"
60+
storage: array # One of "array" or "doctrine"
5561
run:
56-
mode: 'off' # One of "off"; "listener"
62+
mode: 'off' # One of "off" or "listener"
5763
5864
.. _fastcgi_finish_request: http://php.net/manual/en/function.fastcgi-finish-request.php
5965
.. _PHP FPM: http://php.net/manual/en/install.fpm.php

0 commit comments

Comments
 (0)