Skip to content

Commit

Permalink
restructured documentation (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored Oct 15, 2016
1 parent cef3106 commit a93d97e
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 135 deletions.
2 changes: 0 additions & 2 deletions api.rst

This file was deleted.

2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

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

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand Down
308 changes: 214 additions & 94 deletions demo/composer.lock

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

class ImageResizeHandler implements Task\Handler\HandlerInterface
class ImageResizeHandler implements Task\Handler\TaskHandlerInterface
{
/**
* {@inheritdoc}
Expand Down Expand Up @@ -32,27 +32,30 @@ public function handle($workload)
}
}

// bootstrap
$storage = new Task\Storage\ArrayStorage();
$registry = new Task\Handler\Registry();
$taskBuilderFactory = new Task\TaskBuilderFactory();
// storage
$taskRepository = new Task\Storage\ArrayStorage\ArrayTaskRepository();
$taskExecutionRepository = new Task\Storage\ArrayStorage\ArrayTaskExecutionRepository();

// utility
$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$scheduler = new Task\Scheduler($storage, $registry, $taskBuilderFactory, $eventDispatcher);
$taskHandlerFactory = new Task\Handler\TaskHandlerFactory();
$factory = new Task\Builder\TaskBuilderFactory();

// register handler
$registry->add('app.image_resize', new ImageResizeHandler());
// core components
$scheduler = new Task\Scheduler\TaskScheduler($factory, $taskRepository, $taskExecutionRepository, $eventDispatcher);
$runner = new Task\Runner\TaskRunner($taskExecutionRepository, $taskHandlerFactory, $eventDispatcher);

// schedule task one
$scheduler->createTask(
'app.image_resize',
ImageResizeHandler::class,
[__DIR__ . '/images/example-1.jpg', __DIR__ . '/images/thumbnails/example-1.jpg', 100]
)->schedule();

// scheduel task twos
$scheduler->createTask(
'app.image_resize',
ImageResizeHandler::class,
[__DIR__ . '/images/example-2.jpg', __DIR__ . '/images/thumbnails/example-2.jpg', 100]
)->schedule();

// run tasks
$scheduler->run();
$runner->runTasks();
8 changes: 0 additions & 8 deletions implementations.rst

This file was deleted.

2 changes: 0 additions & 2 deletions implementations/gearman.rst

This file was deleted.

2 changes: 0 additions & 2 deletions implementations/php.rst

This file was deleted.

3 changes: 1 addition & 2 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ Welcome to php-task's documentation!
This is the documentation for the php-task library.

Contents:
---------

.. toctree::
:maxdepth: 2

introduction
implementations
symfony
api

Indices and tables
==================
Expand Down
9 changes: 5 additions & 4 deletions introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ What it does
It allows to implement handler classes in PHP for tasks. These handler
can be implemented in your favorite environment. Over a simple
interface the developer can define and schedule long running tasks
without any overhead.
without any overhead for the user of the application.

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

Quick Example
-------------
Expand Down
24 changes: 15 additions & 9 deletions symfony.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ Features
Additional features which are implemented in this bundle.

* Handler discovery
* Automatic registration of frequent tasks
* Different run possibilities
* Different commands to manage and debug commands
* Persist tasks and executions in database
* Run statistics foreach execution of tasks

Installation
------------

.. code-block:: bash
composer require php-task/TaskBundle 1.0-x@dev
composer require php-task/task-bundle 1.0.x-dev
Usage
-----
There are currently two ways to run tasks.

kernel.terminate
^^^^^^^^^^^^^^^^
The tasks will automatically executed when symfony fire this event
which will be fired when the response is sen to the browser.
Event: kernel.terminate
^^^^^^^^^^^^^^^^^^^^^^^
The tasks will automatically executed after sending the response.

.. note::

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

.. code-block:: bash
app/console task:run
.. note::

This option only works if you enable the storage in doctrine which will
persist your tasks in a table-structure.

Configuration Reference
-----------------------

.. code-block:: yaml
task:
storage: array # One of "array"; "doctrine"
storage: array # One of "array" or "doctrine"
run:
mode: 'off' # One of "off"; "listener"
mode: 'off' # One of "off" or "listener"
.. _fastcgi_finish_request: http://php.net/manual/en/function.fastcgi-finish-request.php
.. _PHP FPM: http://php.net/manual/en/install.fpm.php

0 comments on commit a93d97e

Please sign in to comment.