g4/tasker

Application asynchronous tasks manager and runner, cron-like PHP implementation with ability to run tasks with resolution in seconds

Installs: 1 094

Dependents: 0

Stars: 7

Watches: 6

Forks: 2

Language: PHP

0.10.8 2015-06-19 12:04 UTC

README

Tasker - Application asynchronous tasks manager, cron-like PHP implementation with ability to run task in seconds (unlike cron in minutes)

Requires

  • MySQL tables
CREATE TABLE tasks (
    task_id       INT(10)      UNSIGNED          AUTO_INCREMENT,
    recu_id       INT(10)      UNSIGNED NOT NULL DEFAULT 0,
    identifier    VARCHAR(255)          NOT NULL DEFAULT '',
    task          VARCHAR(255)          NOT NULL DEFAULT '',
    data          TEXT,
    status        TINYINT(3)   UNSIGNED NOT NULL DEFAULT 0,
    priority      TINYINT(3)   UNSIGNED NOT NULL DEFAULT 0,
    ts_created    INT(10)      UNSIGNED NOT NULL DEFAULT 0,
    ts_started    INT(10)      UNSIGNED NOT NULL DEFAULT 0,
    exec_time     FLOAT(10,6)  UNSIGNED NOT NULL DEFAULT 0.000000,
    started_count TINYINT(3)   UNSIGNED NOT NULL DEFAULT 0,
    PRIMARY KEY (task_id),
    KEY (recu_id),
    KEY (priority),
    KEY (status),
    KEY pending (status, ts_created),
    KEY started_count (started_count)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE tasks_recurrings (
    recu_id   INT(10)      UNSIGNED          AUTO_INCREMENT,
    frequency VARCHAR(255)          NOT NULL DEFAULT '',
    task      VARCHAR(255)          NOT NULL DEFAULT '',
    data      TEXT,
    status    TINYINT(3)   UNSIGNED NOT NULL DEFAULT 0,
    priority  TINYINT(3)   UNSIGNED NOT NULL DEFAULT 0,
    PRIMARY KEY (recu_id),
    UNIQUE (task),
    KEY (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • Sample data
INSERT INTO tasks_recurrings
    (task, frequency, data, status)
VALUES
    ('Dummy\\Task\\Foo', '0 3-59/15 2,6-12 */15 1 2-5', '{\"foo\":123}', '1'),
    ('Dummy\\Task\\Bar', '0 */5 * * * *',               '{\"bar\":234}', '1'); # runs every 5 minutes

License

(The MIT License) see LICENSE file for details...