1
0

IJobList.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Noveen Sachdeva <noveen.sachdeva@research.iiit.ac.in>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Robin McCorkell <robin@mccorkell.me.uk>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCP\BackgroundJob;
  27. /**
  28. * Interface IJobList
  29. *
  30. * @package OCP\BackgroundJob
  31. * @since 7.0.0
  32. */
  33. interface IJobList {
  34. /**
  35. * Add a job to the list
  36. *
  37. * @param \OCP\BackgroundJob\IJob|string $job
  38. * @param mixed $argument The argument to be passed to $job->run() when the job is exectured
  39. * @since 7.0.0
  40. */
  41. public function add($job, $argument = null);
  42. /**
  43. * Remove a job from the list
  44. *
  45. * @param \OCP\BackgroundJob\IJob|string $job
  46. * @param mixed $argument
  47. * @since 7.0.0
  48. */
  49. public function remove($job, $argument = null);
  50. /**
  51. * check if a job is in the list
  52. *
  53. * @param \OCP\BackgroundJob\IJob|string $job
  54. * @param mixed $argument
  55. * @return bool
  56. * @since 7.0.0
  57. */
  58. public function has($job, $argument);
  59. /**
  60. * get all jobs in the list
  61. *
  62. * @return \OCP\BackgroundJob\IJob[]
  63. * @since 7.0.0
  64. * @deprecated 9.0.0 - This method is dangerous since it can cause load and
  65. * memory problems when creating too many instances.
  66. */
  67. public function getAll();
  68. /**
  69. * get the next job in the list
  70. *
  71. * @return \OCP\BackgroundJob\IJob|null
  72. * @since 7.0.0
  73. */
  74. public function getNext();
  75. /**
  76. * @param int $id
  77. * @return \OCP\BackgroundJob\IJob|null
  78. * @since 7.0.0
  79. */
  80. public function getById($id);
  81. /**
  82. * set the job that was last ran to the current time
  83. *
  84. * @param \OCP\BackgroundJob\IJob $job
  85. * @since 7.0.0
  86. */
  87. public function setLastJob(IJob $job);
  88. /**
  89. * Remove the reservation for a job
  90. *
  91. * @param IJob $job
  92. * @since 9.1.0
  93. */
  94. public function unlockJob(IJob $job);
  95. /**
  96. * get the id of the last ran job
  97. *
  98. * @return int
  99. * @since 7.0.0
  100. * @deprecated 9.1.0 - The functionality behind the value is deprecated, it
  101. * only tells you which job finished last, but since we now allow multiple
  102. * executors to run in parallel, it's not used to calculate the next job.
  103. */
  104. public function getLastJob();
  105. /**
  106. * set the lastRun of $job to now
  107. *
  108. * @param IJob $job
  109. * @since 7.0.0
  110. */
  111. public function setLastRun(IJob $job);
  112. /**
  113. * set the run duration of $job
  114. *
  115. * @param IJob $job
  116. * @param $timeTaken
  117. * @since 12.0.0
  118. */
  119. public function setExecutionTime(IJob $job, $timeTaken);
  120. }