IJob.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP\BackgroundJob;
  25. use OCP\ILogger;
  26. /**
  27. * Interface IJob
  28. *
  29. * @package OCP\BackgroundJob
  30. * @since 7.0.0
  31. */
  32. interface IJob {
  33. /**
  34. * Run the background job with the registered argument
  35. *
  36. * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job
  37. * @param ILogger $logger
  38. * @since 7.0.0
  39. */
  40. public function execute($jobList, ILogger $logger = null);
  41. /**
  42. * @param int $id
  43. * @since 7.0.0
  44. */
  45. public function setId($id);
  46. /**
  47. * @param int $lastRun
  48. * @since 7.0.0
  49. */
  50. public function setLastRun($lastRun);
  51. /**
  52. * @param mixed $argument
  53. * @since 7.0.0
  54. */
  55. public function setArgument($argument);
  56. /**
  57. * Get the id of the background job
  58. * This id is determined by the job list when a job is added to the list
  59. *
  60. * @return int
  61. * @since 7.0.0
  62. */
  63. public function getId();
  64. /**
  65. * Get the last time this job was run as unix timestamp
  66. *
  67. * @return int
  68. * @since 7.0.0
  69. */
  70. public function getLastRun();
  71. /**
  72. * Get the argument associated with the background job
  73. * This is the argument that will be passed to the background job
  74. *
  75. * @return mixed
  76. * @since 7.0.0
  77. */
  78. public function getArgument();
  79. }