From a7015b76d8bf9020694b5e513c5141cd705b22ed Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Mon, 5 Dec 2016 09:36:38 +0100 Subject: [PATCH] improve documentation for 0.4 release --- components.rst | 36 ++++ demo/composer.lock | 247 +++++++++----------------- img/state-machine.ditaa | 15 ++ img/state-machine.png | Bin 0 -> 8942 bytes index.rst | 34 +++- introduction.rst => quick-example.rst | 51 ++---- symfony.rst | 2 +- 7 files changed, 180 insertions(+), 205 deletions(-) create mode 100644 components.rst create mode 100644 img/state-machine.ditaa create mode 100644 img/state-machine.png rename introduction.rst => quick-example.rst (58%) diff --git a/components.rst b/components.rst new file mode 100644 index 0000000..c235de6 --- /dev/null +++ b/components.rst @@ -0,0 +1,36 @@ +Components +========== +The library consists of three main parts. + +TaskScheduler +------------- +The ``TaskScheduler`` stores tasks and schedules executions. For each task +there exists exactly one execution in the status ``planned`` or ``running``. If +the task will only one time it only get one execution at all. For recurring +tasks a new execution will be generated when the old one is ``completed`` or +``failed``. + +Each task consists of: + +- ``uuid``: unique identifier +- ``handlerClass``: class-name of the handler which will be executed for this + task +- ``workload``: the workload will be passed to the handler +- ``interval``: for recurring tasks this fields contains a cron-expression +- ``firstExecution``: the earliest possible execution +- ``lastExecution``: the latest possible execution + +TaskRunner +---------- +The ``TaskRunner`` takes the ``planned`` executions and executes the ``Handler`` +with the workload of the task. + +Handler +------- +The ``Handler`` implements the domain-logic for a task. The library implements +a Factory which uses Reflection to create a new instance for the +``handlerClass`` of the task. + +.. note:: + + The :doc:`symfony` uses tagged-services to find available ``Handler``. diff --git a/demo/composer.lock b/demo/composer.lock index 9282fc0..b290983 100644 --- a/demo/composer.lock +++ b/demo/composer.lock @@ -9,35 +9,35 @@ "packages": [ { "name": "doctrine/annotations", - "version": "v1.2.7", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" + "reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/30e07cf03edc3cd3ef579d0dd4dd8c58250799a5", + "reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": ">=5.3.2" + "php": "^5.6 || ^7.0" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^5.6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" } }, "notification-url": "https://packagist.org/downloads/", @@ -73,20 +73,20 @@ "docblock", "parser" ], - "time": "2015-08-31 12:32:49" + "time": "2016-10-24 11:45:47" }, { "name": "doctrine/cache", - "version": "v1.6.0", + "version": "v1.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b6f544a20f4807e81f7044d31e679ccbb1866dc3", + "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3", "shasum": "" }, "require": { @@ -143,7 +143,7 @@ "cache", "caching" ], - "time": "2015-12-31 16:37:02" + "time": "2016-10-29 11:16:17" }, { "name": "doctrine/collections", @@ -213,16 +213,16 @@ }, { "name": "doctrine/common", - "version": "v2.6.1", + "version": "v2.6.2", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "a579557bc689580c19fee4e27487a67fe60defc0" + "reference": "7bce00698899aa2c06fe7365c76e4d78ddb15fa3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0", - "reference": "a579557bc689580c19fee4e27487a67fe60defc0", + "url": "https://api.github.com/repos/doctrine/common/zipball/7bce00698899aa2c06fe7365c76e4d78ddb15fa3", + "reference": "7bce00698899aa2c06fe7365c76e4d78ddb15fa3", "shasum": "" }, "require": { @@ -282,7 +282,7 @@ "persistence", "spl" ], - "time": "2015-12-25 13:18:31" + "time": "2016-11-30 16:50:46" }, { "name": "doctrine/dbal", @@ -606,84 +606,6 @@ ], "time": "2016-09-10 18:51:13" }, - { - "name": "monolog/monolog", - "version": "1.21.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^2.4.9", - "doctrine/couchdb": "~1.0@dev", - "graylog2/gelf-php": "~1.0", - "jakub-onderka/php-parallel-lint": "0.9", - "php-amqplib/php-amqplib": "~2.4", - "php-console/php-console": "^3.1.3", - "phpunit/phpunit": "~4.5", - "phpunit/phpunit-mock-objects": "2.3.0", - "ruflin/elastica": ">=0.90 <3.0", - "sentry/sentry": "^0.13", - "swiftmailer/swiftmailer": "~5.3" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "php-console/php-console": "Allow sending log messages to Google Chrome", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "sentry/sentry": "Allow sending log messages to a Sentry server" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "http://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ], - "time": "2016-07-29 03:23:52" - }, { "name": "mtdowling/cron-expression", "version": "v1.1.0", @@ -730,16 +652,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.2", + "version": "v2.0.4", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "088c04e2f261c33bed6ca5245491cfca69195ccf" + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/088c04e2f261c33bed6ca5245491cfca69195ccf", - "reference": "088c04e2f261c33bed6ca5245491cfca69195ccf", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", "shasum": "" }, "require": { @@ -774,7 +696,7 @@ "pseudorandom", "random" ], - "time": "2016-04-03 06:00:07" + "time": "2016-11-07 23:38:38" }, { "name": "php-task/php-task", @@ -782,17 +704,16 @@ "source": { "type": "git", "url": "https://github.com/php-task/php-task.git", - "reference": "aad910663725acf77b5da0e44af2aeedc731c523" + "reference": "d9229fb815ca49f288b186cce0bd93043db9c66d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-task/php-task/zipball/aad910663725acf77b5da0e44af2aeedc731c523", - "reference": "aad910663725acf77b5da0e44af2aeedc731c523", + "url": "https://api.github.com/repos/php-task/php-task/zipball/d9229fb815ca49f288b186cce0bd93043db9c66d", + "reference": "d9229fb815ca49f288b186cce0bd93043db9c66d", "shasum": "" }, "require": { "doctrine/common": "^2.6", - "monolog/monolog": "^1.17", "mtdowling/cron-expression": "^1.1", "php": "~5.5 || ~7.0", "ramsey/uuid": "^3.1", @@ -823,7 +744,7 @@ } ], "description": "Interfaces to work with synchronous and asynchronous tasks in php.", - "time": "2016-10-12 18:49:38" + "time": "2016-11-29 10:43:35" }, { "name": "php-task/task-bundle", @@ -831,17 +752,17 @@ "source": { "type": "git", "url": "https://github.com/php-task/TaskBundle.git", - "reference": "35d2f68956bde298961c9035f21c436b9eab02d2" + "reference": "8d804670fee5dfec7c4b75d87f442d656663b1ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-task/TaskBundle/zipball/35d2f68956bde298961c9035f21c436b9eab02d2", - "reference": "35d2f68956bde298961c9035f21c436b9eab02d2", + "url": "https://api.github.com/repos/php-task/TaskBundle/zipball/8d804670fee5dfec7c4b75d87f442d656663b1ef", + "reference": "8d804670fee5dfec7c4b75d87f442d656663b1ef", "shasum": "" }, "require": { "doctrine/orm": "^2.5", - "php": "~5.6 || ~7.0", + "php": "~5.5 || ~7.0", "php-task/php-task": "dev-master", "symfony/config": "^2.6", "symfony/console": "^2.6", @@ -849,7 +770,7 @@ "symfony/http-kernel": "^2.6" }, "require-dev": { - "doctrine/data-fixtures": "^1.2", + "doctrine/data-fixtures": "^1.1", "doctrine/doctrine-bundle": "^1.5", "phpunit/phpunit": "^4.8", "symfony/finder": "^2.6", @@ -877,7 +798,7 @@ } ], "description": "Symfony integration for php-task library", - "time": "2016-10-12 18:52:19" + "time": "2016-11-29 10:50:45" }, { "name": "psr/log", @@ -928,16 +849,16 @@ }, { "name": "ramsey/uuid", - "version": "3.5.1", + "version": "3.5.2", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "a07797b986671b0dc823885a81d5e3516b931599" + "reference": "5677cfe02397dd6b58c861870dfaa5d9007d3954" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/a07797b986671b0dc823885a81d5e3516b931599", - "reference": "a07797b986671b0dc823885a81d5e3516b931599", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/5677cfe02397dd6b58c861870dfaa5d9007d3954", + "reference": "5677cfe02397dd6b58c861870dfaa5d9007d3954", "shasum": "" }, "require": { @@ -950,11 +871,13 @@ "require-dev": { "apigen/apigen": "^4.1", "codeception/aspect-mock": "1.0.0", + "doctrine/annotations": "~1.2.0", "goaop/framework": "1.0.0-alpha.2", "ircmaxell/random-lib": "^1.1", "jakub-onderka/php-parallel-lint": "^0.9.0", "mockery/mockery": "^0.9.4", "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", "phpunit/phpunit": "^4.7|>=5.0 <5.4", "satooshi/php-coveralls": "^0.6.1", "squizlabs/php_codesniffer": "^2.3" @@ -1004,20 +927,20 @@ "identifier", "uuid" ], - "time": "2016-10-02 15:51:17" + "time": "2016-11-22 19:21:44" }, { "name": "symfony/config", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "f8b1922bbda9d2ac86aecd649399040bce849fde" + "reference": "1361bc4e66f97b6202ae83f4190e962c624b5e61" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/f8b1922bbda9d2ac86aecd649399040bce849fde", - "reference": "f8b1922bbda9d2ac86aecd649399040bce849fde", + "url": "https://api.github.com/repos/symfony/config/zipball/1361bc4e66f97b6202ae83f4190e962c624b5e61", + "reference": "1361bc4e66f97b6202ae83f4190e962c624b5e61", "shasum": "" }, "require": { @@ -1057,20 +980,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-09-14 20:31:12" + "time": "2016-11-03 07:52:58" }, { "name": "symfony/console", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4" + "reference": "a871ba00e0f604dceac64c56c27f99fbeaf4854e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d7a5a88178f94dcc29531ea4028ea614e35452d4", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4", + "url": "https://api.github.com/repos/symfony/console/zipball/a871ba00e0f604dceac64c56c27f99fbeaf4854e", + "reference": "a871ba00e0f604dceac64c56c27f99fbeaf4854e", "shasum": "" }, "require": { @@ -1118,20 +1041,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-09-28 00:10:16" + "time": "2016-11-15 23:02:12" }, { "name": "symfony/debug", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "8c29235936a47473af16fb91c7c4b7b193c5693c" + "reference": "62a68f640456f6761d752c62d81631428ef0d8a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/8c29235936a47473af16fb91c7c4b7b193c5693c", - "reference": "8c29235936a47473af16fb91c7c4b7b193c5693c", + "url": "https://api.github.com/repos/symfony/debug/zipball/62a68f640456f6761d752c62d81631428ef0d8a1", + "reference": "62a68f640456f6761d752c62d81631428ef0d8a1", "shasum": "" }, "require": { @@ -1175,20 +1098,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-11-15 12:53:17" }, { "name": "symfony/dependency-injection", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75" + "reference": "9d2c5033ca70ceade8d7584f997a9d3943f0fe5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ee9ec9ac2b046462d341e9de7c4346142d335e75", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/9d2c5033ca70ceade8d7584f997a9d3943f0fe5f", + "reference": "9d2c5033ca70ceade8d7584f997a9d3943f0fe5f", "shasum": "" }, "require": { @@ -1238,20 +1161,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-09-24 09:47:20" + "time": "2016-11-18 21:10:01" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8" + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/889983a79a043dfda68f38c38b6dba092dd49cd8", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", "shasum": "" }, "require": { @@ -1298,7 +1221,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-28 16:56:28" + "time": "2016-10-13 01:43:15" }, { "name": "symfony/filesystem", @@ -1351,16 +1274,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.0.9", + "version": "v3.1.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "49ba00f8ede742169cb6b70abe33243f4d673f82" + "reference": "5a4c8099a1547fe451256e056180ad4624177017" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/49ba00f8ede742169cb6b70abe33243f4d673f82", - "reference": "49ba00f8ede742169cb6b70abe33243f4d673f82", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5a4c8099a1547fe451256e056180ad4624177017", + "reference": "5a4c8099a1547fe451256e056180ad4624177017", "shasum": "" }, "require": { @@ -1373,7 +1296,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1400,20 +1323,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2016-07-17 13:54:30" + "time": "2016-11-16 22:17:09" }, { "name": "symfony/http-kernel", - "version": "v2.8.12", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "0e39ed020c6a4bfb888974414fbfe2779637a487" + "reference": "29d9bb59c6d895e65d8fea3859c96c3b6e9368ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/0e39ed020c6a4bfb888974414fbfe2779637a487", - "reference": "0e39ed020c6a4bfb888974414fbfe2779637a487", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/29d9bb59c6d895e65d8fea3859c96c3b6e9368ba", + "reference": "29d9bb59c6d895e65d8fea3859c96c3b6e9368ba", "shasum": "" }, "require": { @@ -1421,7 +1344,7 @@ "psr/log": "~1.0", "symfony/debug": "~2.6,>=2.6.2", "symfony/event-dispatcher": "~2.6,>=2.6.7|~3.0.0", - "symfony/http-foundation": "~2.7.15|~2.8.8|~3.0.8" + "symfony/http-foundation": "~2.7.20|~2.8.13|~3.1.6" }, "conflict": { "symfony/config": "<2.7" @@ -1482,20 +1405,20 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2016-10-03 18:44:05" + "time": "2016-11-21 02:24:42" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -1507,7 +1430,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -1541,7 +1464,7 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14 01:06:16" } ], "packages-dev": [], diff --git a/img/state-machine.ditaa b/img/state-machine.ditaa new file mode 100644 index 0000000..0d4314d --- /dev/null +++ b/img/state-machine.ditaa @@ -0,0 +1,15 @@ ++-----------------+ +-------------+ +-------------+ +| planned | ----> | running | -+--> | completed | ++-----------------+ +-------------+ | +-------------+ +| - scheduleTime | | - startTime | | | - result | ++-----------------+ +-------------+ | | - endTime | + | | - duration | + | +-------------+ + | + | +-------------+ + +--> | failed | + +-------------+ + | - exception | + | - endTime | + | - duration | + +-------------+ diff --git a/img/state-machine.png b/img/state-machine.png new file mode 100644 index 0000000000000000000000000000000000000000..40c82d90a16bc847adf8b4a034cb013a47569713 GIT binary patch literal 8942 zcmch7XIN9)+AY}F7QhP9RhmdsiU^^pbO=cAV5K*M1R*plAXR!tL+>D=h9aWU!2|-B z5D@8+fV7~LaA&}M&e`XF_x`v)uFn&Ywbq>LopZirjPWM)maaPE5%wc=baafG8Y%{K zbo(;s=;)99wGUj8I{M)l9o>a0O_l3LkMU$8LdR%syKU*9{(FvBVHyXl&s_W#|KZZ8 zbf=TSNmFa_ttVC2U#Oip_1Eo&DgiU1k`wZJ2|K?v5~I4L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EQPNJ;|BDO;|+nPqKnyocb0x99L8&_ehhcK(nG z*g0hUX+v)zV0-`o8$s*>V)H<4HruRigp^$ZCp!CZ7ioS=!jvinbI{U7x+?msUJoR4 zyLaCnV`6#M;_+iplpOe>W_V?n)CD=XhekyuzVIF&!h<&lfkp|H)9uG#iDCb{f@#oU z%rUpJDo(+3x}o9ZBTP)aU0t!gfSt|G&c1nbZcbA}qt<&d!?%1Dfk1S9@b~whG6$-p zsH@$RQ{c!`75(ewC8VSt0dnT$!z`7eqWt-sM{446|lvp2agUsoBE~9C8O~tTUVogMUThml%5JN zRyH&=46EAZUVkVM$akPy0zjQBtJv%LT`ZM79qD|<`}*iL{DbqL$AfKnIPp?ytPvq7 zB-R7aUG?l9xdfh}bbnd~unaH<12eaj4XAifH8nLI9i994v*p}w4ULwlZRThv4ji}) za;c5^(^Wox{;EI2uQ~4|<77u%Lg8dsee})e;PABVjf@6B5DeT2j=*H3r;FB1sWgM; zG7$~>Rjv#0?La?mTH&W;nx(h8PIo6`?or=nHd4u%t0Qms;Nkbb*qRED5ZG1w4 zZic-1_FXd2^-aXv!+`QrTVJo0--S^IO&_@vraYNluRp#zBRsIw0=ODp>@84C0r9rx zi01E3hpYq0YiAp_8|W8;T8I|SX67MnIUpaWB6S{A-ove!N7?dM=;=T`K~-v*uK z_1#4EZ{GDckJ|-9%AocCUtoxaoD?r#{jyCXi8L%k`|N%T;~(F^pdl(6G5g1tHU9TU r!EOSw^~ literal 0 HcmV?d00001 diff --git a/index.rst b/index.rst index f128dcf..d18db4c 100644 --- a/index.rst +++ b/index.rst @@ -1,16 +1,37 @@ Welcome to php-task's documentation! ==================================== +PHP-Task provides a simple to use task-scheduling library. It provides an array +storage for simple usecases. In case your are using the +:doc:`symfony-bundle` you can also use the doctrine-storage which +persists the tasks in a simple database structure. -This is the documentation for the php-task library. +Basic Ideas +----------- +The basic idea behind the library is to decouple the scheduling and running the +tasks. The scheduling is done by a ``TaskScheduler`` which stores Tasks and +schedule its executions. This executions will be executed by the ``TaskRunner``. -Contents: ---------- +Each Execution has a lifecycle with following state-machine: + +.. figure:: img/state-machine.png + +This decoupled architectures allows you schedule recurring tasks. To define this +tasks you can use `Cron Expression`_ to define when and how often (e.g. each +Tuesday on 12am) the task should run. + +After each execution the ``TaskScheduler`` will be called to schedule a new +execution for the recurring task. This allows to persist the history of +executions and make statistics over results, statuses and durations. + +Contents +-------- .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - introduction - symfony + components + quick-example + symfony Indices and tables ================== @@ -19,3 +40,4 @@ Indices and tables * :ref:`modindex` * :ref:`search` +.. _Cron Expression: https://github.com/mtdowling/cron-expression diff --git a/introduction.rst b/quick-example.rst similarity index 58% rename from introduction.rst rename to quick-example.rst index a4535a8..cda5ad7 100644 --- a/introduction.rst +++ b/quick-example.rst @@ -1,22 +1,5 @@ -Introduction -============ -The php-task library provides a simple and easy to extend interface -to handle synchronous and asynchronous tasks in PHP. - -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 for the user of the application. - -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 -------------- +============= This example will assume you want to generate thumbnail images. .. code-block:: php @@ -25,7 +8,7 @@ This example will assume you want to generate thumbnail images. include __DIR__ . '/vendor/autoload.php'; - class ImageResizeHandler implements Task\Handler\HandlerInterface + class ImageResizeHandler implements Task\Handler\TaskHandlerInterface { /** * {@inheritdoc} @@ -55,30 +38,33 @@ This example will assume you want to generate thumbnail images. } } - // 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('iapp.mage_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(); The example will generate two thumbnail images one for the jpg ``example-1.jpg`` and one for ``example-2.jpg`` both in the folder thumbnails. @@ -87,11 +73,4 @@ and one for ``example-2.jpg`` both in the folder thumbnails. You find the `complete source-code`_ for this example here -Integration ------------ -The library provides a integration into Symfony_ framework (see :doc:`symfony`). - -.. _Gearman: http://gearman.org -.. _PHP Implementation: https://github.com/php-task/php -.. _Symfony: http://symfony.com/ .. _complete source-code: https://github.com/php-task/docs/tree/master/demo diff --git a/symfony.rst b/symfony.rst index 9b0b3fd..377722a 100644 --- a/symfony.rst +++ b/symfony.rst @@ -6,7 +6,7 @@ Features -------- Additional features which are implemented in this bundle. -* Handler discovery +* Handler discovery (over ``task.handler``-tag) * Different run possibilities * Different commands to manage and debug commands * Persist tasks and executions in database