You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
992 B

  1. <?php
  2. /**
  3. * 计划任务客户端类 Task_Lite
  4. *
  5. * @author dogstar <chanzonghuang@gmail.com> 20150516
  6. */
  7. class Task_Lite {
  8. /**
  9. * Task_MQ $mq MQ队列
  10. */
  11. protected $mq;
  12. public function __construct(Task_MQ $mq) {
  13. $this->mq = $mq;
  14. DI()->loader->addDirs('./Library/Task/Task');
  15. }
  16. /**
  17. * 添加一个计划任务到MQ队列
  18. * @param string $service 接口服务名称,如:Default.Index
  19. * @param array $params 接口服务参数
  20. */
  21. public function add($service, $params = array()) {
  22. if (empty($service) || count(explode('.', $service)) < 2) {
  23. return FALSE;
  24. }
  25. if (!is_array($params)) {
  26. return FALSE;
  27. }
  28. $rs = $this->mq->add($service, $params);
  29. if (!$rs) {
  30. DI()->logger->debug('task add a new mq',
  31. array('service' => $service, 'params' => $params));
  32. return FALSE;
  33. }
  34. return TRUE;
  35. }
  36. }