定制 riesenia/scheduler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

riesenia/scheduler

最新稳定版本:v2.1.0

Composer 安装命令:

composer require riesenia/scheduler

包简介

PHP class providing simple scheduling functionality

README 文档

README

PHP script providing basic scheduling functionality.

Installation

Install the latest version using composer require riesenia/scheduler

Or add to your composer.json file as a requirement:

{
    "require": {
        "riesenia/scheduler": "~1.0"
    }
}

Usage

Constructor takes two parameters:

  • items - array of integers - item IDs
  • terms - array of TermInterface
use Riesenia\Scheduler\Scheduler;

$items = [1, 2];
$terms = [$term1, $term2, $term3, $term4];

$scheduler = new Scheduler($items, $terms);

Adding terms and Items

Items and Terms can be also added separately. All added terms have to implement TermInterface.

$scheduler->addItem(3);
$scheduler->addTerm($term5);

TermInterface

Term is defined by its starting and ending date (getFrom() and getTo() methods). Moreover it can be locked to specific item by providing its ID in getLockedId() method.

Scheduling

Calling schedule() method distributes terms to items correctly. If this is not possible, scheduler throws SchedulerException with the information which terms overlap.

use Riesenia\Scheduler\SchedulerException;

try {
    $scheduler->schedule();

    // get all the terms with reassigned item IDs
    $scheduler->getTerms();
} catch (SchedulerException $e) {
    \var_dump($e->getConflictingTerms());
}

External solver binary

For large inputs, the built-in PHP backtracking solver may be too slow. The package includes an optional Rust-based solver in the solver/ directory that uses parallel search for significantly better performance.

Build the binary:

cd solver
cargo build --release
# binary will be at solver/target/release/scheduler-solver

Then point the scheduler to it:

$scheduler->setSolverBinary('/path/to/scheduler-solver');

The solver communicates via JSON over stdin/stdout and is fully compatible with the PHP solver — same input, same results.

Timeout

Both the PHP and external solver support a timeout (in seconds). If the scheduler does not find a solution within the given time, it throws SchedulerException.

$scheduler->setTimeout(10);

When using the external solver, the timeout is passed in the JSON input and handled natively by the Rust binary — the process exits cleanly with a timeout status.

统计信息

  • 总下载量: 612
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固