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.

39 lines
810B

  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Foundation\Bus\Dispatchable;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Queue\SerializesModels;
  8. use Illuminate\Support\Facades\Log;
  9. abstract class BaseJob implements ShouldQueue
  10. {
  11. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  12. public function handle()
  13. {
  14. $this->logConfig();
  15. $this->handleJob();
  16. }
  17. /**
  18. * ジョブを再試行する前に待機する秒数を計算
  19. */
  20. public function backoff(): int
  21. {
  22. return 5;
  23. }
  24. abstract protected function handleJob();
  25. private function logConfig()
  26. {
  27. Log::withContext([
  28. '__job_class__' => staitc::class,
  29. ]);
  30. }
  31. }