Service.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace think\queue;
  3. use think\helper\Arr;
  4. use think\helper\Str;
  5. use think\Queue;
  6. use think\queue\command\FailedTable;
  7. use think\queue\command\FlushFailed;
  8. use think\queue\command\ForgetFailed;
  9. use think\queue\command\Listen;
  10. use think\queue\command\ListFailed;
  11. use think\queue\command\Restart;
  12. use think\queue\command\Retry;
  13. use think\queue\command\Table;
  14. use think\queue\command\Work;
  15. class Service extends \think\Service
  16. {
  17. public function register()
  18. {
  19. $this->app->bind('queue', Queue::class);
  20. $this->app->bind('queue.failer', function () {
  21. $config = $this->app->config->get('queue.failed', []);
  22. $type = Arr::pull($config, 'type', 'none');
  23. $class = false !== strpos($type, '\\') ? $type : '\\think\\queue\\failed\\' . Str::studly($type);
  24. return $this->app->invokeClass($class, [$config]);
  25. });
  26. }
  27. public function boot()
  28. {
  29. $this->commands([
  30. FailedJob::class,
  31. Table::class,
  32. FlushFailed::class,
  33. ForgetFailed::class,
  34. ListFailed::class,
  35. Retry::class,
  36. Work::class,
  37. Restart::class,
  38. Listen::class,
  39. FailedTable::class,
  40. ]);
  41. }
  42. }