All Projects → glooby → task-bundle

glooby / task-bundle

Licence: MIT license
Scheduling of tasks for symfony made simple

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to task-bundle

Pg timetable
pg_timetable: Advanced scheduling for PostgreSQL
Stars: ✭ 382 (+1057.58%)
Mutual labels:  scheduling, interval
interval
This PHP library provides some tools to handle intervals. For instance, you can compute the union or intersection of two intervals.
Stars: ✭ 25 (-24.24%)
Mutual labels:  scheduling, interval
clothing-detection-ecommerce-dataset
Clothing detection dataset
Stars: ✭ 43 (+30.3%)
Mutual labels:  annotations
Easy-Fragment-Argument
This library will help you to pass and receive fragment arguments in easier way
Stars: ✭ 17 (-48.48%)
Mutual labels:  annotations
Flow-Shop-Scheduling-Based-On-Reinforcement-Learning-Algorithm
Operations Research Application Project - Flow Shop Scheduling Based On Reinforcement Learning Algorithm
Stars: ✭ 73 (+121.21%)
Mutual labels:  scheduling
annotate
Create 3D labelled bounding boxes in RViz
Stars: ✭ 104 (+215.15%)
Mutual labels:  annotations
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+412.12%)
Mutual labels:  scheduling
young-examples
java学习和项目中一些典型的应用场景样例代码
Stars: ✭ 21 (-36.36%)
Mutual labels:  annotations
twc
TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
Stars: ✭ 33 (+0%)
Mutual labels:  annotations
hyperion
Experimental framework for working with IIIF in JavaScript and Typescript.
Stars: ✭ 17 (-48.48%)
Mutual labels:  annotations
vent
Vent is a light-weight platform built to automate network collection and analysis pipelines using a flexible set of popular open source tools and technologies. Vent is python-based, extensible, leverages docker containers, and provides both an API and CLI.
Stars: ✭ 73 (+121.21%)
Mutual labels:  scheduling
symbok-bundle
Symfony annotations bundle
Stars: ✭ 50 (+51.52%)
Mutual labels:  annotations
wat
How fast are computers?
Stars: ✭ 26 (-21.21%)
Mutual labels:  scheduling
amigo
AmiGO is the public interface for the Gene Ontology.
Stars: ✭ 26 (-21.21%)
Mutual labels:  annotations
code-art
🌈 Collect beautiful art text, never bug. 收集好看的艺术代码,佛祖保佑,永无 Bug。找好看的注释,看这里。
Stars: ✭ 38 (+15.15%)
Mutual labels:  annotations
aioapi
Yet another way to build APIs using AIOHTTP framework
Stars: ✭ 14 (-57.58%)
Mutual labels:  annotations
anor
anor: an annotation and visualization system based on R and Shiny framework
Stars: ✭ 28 (-15.15%)
Mutual labels:  annotations
GdprBundle
A symfony3 bundle to assist with defining data in accordance with GDPR, and for encrypting and reporting.
Stars: ✭ 61 (+84.85%)
Mutual labels:  annotations
delay-timer
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible scheduling, and dynamic add/cancel/remove is supported.
Stars: ✭ 257 (+678.79%)
Mutual labels:  scheduling
numeric
numeric facilities for C++ 14; dual numbers, dual quaternions, constrained numbers, intervals
Stars: ✭ 21 (-36.36%)
Mutual labels:  interval

task-bundle

Build Status Scrutinizer Code Quality Coverage Status Latest Stable Version Total Downloads License

Provides a simple framework to manage scheduling and execution of tasks Symfony application.

Prerequisite

This bundle requires cron to be installed on the server to be able to execute scheduled tasks

Installation

Add the glooby/task-bundle package to your require section in the composer.json file.

$ composer require glooby/task-bundle ~3.0

Add the GloobyTaskBundle to your application's kernel:

<?php
public function registerBundles()
{
    $bundles = [
        // ...
        new Glooby\TaskBundle\GloobyTaskBundle(),
        // ...
    ];
    ...
}

Create this file /etc/cron.d/glooby_scheduler_run

* * * * *  nginx  cd /path/to/project && php bin/console scheduler:run --env=prod &> /dev/null 2>&1

Documentation

Create a executable Task

To setup a new runnable task you should follow these steps

Implement the TaskInterface

example: src/Glooby/Api/TaskBundle/Task/PingTask.php

    class PingTask implements TaskInterface
    {
        /**
         * @inheritdoc
         */
        public function run(array $params = [])
        {
            return 'pong';
        }
    }

Add a service for your task

services:
    glooby_task.ping:
        class: Glooby\TaskBundle\Task\PingTask

Try and run the task trough cli

    $ bin/console task:run glooby_task.ping

    "pong"

Setup Scheduled task

To setup a new schedule you should follow the steps below

Make your service runnable

Follow the steps in [Create a executable Task](#Create a executable Task)

Tag your service

By tagging your service with the glooby.scheduled_task tag it will be treated as a scheduled task

example:

src/Glooby/Api/TaskBundle/Resources/config/services.yml

services:
    glooby_task.ping:
        class: Glooby\TaskBundle\Task\PingTask
        tags:
            - { name: glooby.scheduled_task }

Annotate your class

Annotate your class with this annotation: Glooby\TaskBundle\Annotation\Schedule

Parameters
interval

The first parameter to the annotation is defaulted to the interval parameter. In this parameter you configure the interval that the service should be executed.

The interval is a string of five or optional six subexpressions that describe details of the schedule. The syntax is based on the Linux cron daemon definition.

    *    *    *    *    *    *
    -    -    -    -    -    -
    |    |    |    |    |    |
    |    |    |    |    |    + year [optional]
    |    |    |    |    +----- day of week (0 - 7) (Sunday=0 or 7)
    |    |    |    +---------- month (1 - 12)
    |    |    +--------------- day of month (1 - 31)
    |    +-------------------- hour (0 - 23)
    +------------------------- min (0 - 59)

This is the only required parameter

use Glooby\TaskBundle\Annotation\Schedule;

/**
 * @Schedule("* * * * *")
 */
class PingTask implements TaskInterface
{

Here you have several shortcuts that you can use instead for most common use cases

value interval
@yearly 0 0 1 1 *
@annually 0 0 1 1 *
@monthly 0 0 1 * *
@weekly 0 0 * * 0
@daily 0 0 * * *
@hourly 0 * * * *
@semi_hourly */30 * * * *
@quarter_hourly */15 * * * *
* * * * * *
use Glooby\TaskBundle\Annotation\Schedule;

/**
 * @Schedule("@hourly")
 */
class PingTask implements TaskInterface
{
params

The params that should be used when calling

use Glooby\TaskBundle\Annotation\Schedule;

/**
* @Schedule("@weekly", params={"wash": true, "flush": 500})
*/
class CityImporter implements TaskInterface
{
active

Phe active parameter tells if the schedule should be active or not, default=true

use Glooby\TaskBundle\Annotation\Schedule;

/**
* @Schedule("*/6", active=false)
*/
class PingTask implements TaskInterface
{

Sync schedules to the database, this has to be run after each update

bin/console scheduler:run

Running the Tests

Install the dependencies:

$ script/bootstrap

Then, run the test suite:

$ script/test

Contributing

See CONTRIBUTING file.

License

This bundle is released under the MIT license. See the complete license in the bundle: LICENSE.md

www.glooby.com www.glooby.se

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].