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.

IJobList.php 3.0KB

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