BatchRepository.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace Illuminate\Bus;
  3. use Closure;
  4. interface BatchRepository
  5. {
  6. /**
  7. * Retrieve a list of batches.
  8. *
  9. * @param int $limit
  10. * @param mixed $before
  11. * @return \Illuminate\Bus\Batch[]
  12. */
  13. public function get($limit, $before);
  14. /**
  15. * Retrieve information about an existing batch.
  16. *
  17. * @param string $batchId
  18. * @return \Illuminate\Bus\Batch|null
  19. */
  20. public function find(string $batchId);
  21. /**
  22. * Store a new pending batch.
  23. *
  24. * @param \Illuminate\Bus\PendingBatch $batch
  25. * @return \Illuminate\Bus\Batch
  26. */
  27. public function store(PendingBatch $batch);
  28. /**
  29. * Increment the total number of jobs within the batch.
  30. *
  31. * @param string $batchId
  32. * @param int $amount
  33. * @return void
  34. */
  35. public function incrementTotalJobs(string $batchId, int $amount);
  36. /**
  37. * Decrement the total number of pending jobs for the batch.
  38. *
  39. * @param string $batchId
  40. * @param string $jobId
  41. * @return \Illuminate\Bus\UpdatedBatchJobCounts
  42. */
  43. public function decrementPendingJobs(string $batchId, string $jobId);
  44. /**
  45. * Increment the total number of failed jobs for the batch.
  46. *
  47. * @param string $batchId
  48. * @param string $jobId
  49. * @return \Illuminate\Bus\UpdatedBatchJobCounts
  50. */
  51. public function incrementFailedJobs(string $batchId, string $jobId);
  52. /**
  53. * Mark the batch that has the given ID as finished.
  54. *
  55. * @param string $batchId
  56. * @return void
  57. */
  58. public function markAsFinished(string $batchId);
  59. /**
  60. * Cancel the batch that has the given ID.
  61. *
  62. * @param string $batchId
  63. * @return void
  64. */
  65. public function cancel(string $batchId);
  66. /**
  67. * Delete the batch that has the given ID.
  68. *
  69. * @param string $batchId
  70. * @return void
  71. */
  72. public function delete(string $batchId);
  73. /**
  74. * Execute the given Closure within a storage specific transaction.
  75. *
  76. * @param \Closure $callback
  77. * @return mixed
  78. */
  79. public function transaction(Closure $callback);
  80. /**
  81. * Rollback the last database transaction for the connection.
  82. *
  83. * @return void
  84. */
  85. public function rollBack();
  86. }