Issues (48)

src/PheanstalkInterface.php (3 issues)

1
<?php
2
3
namespace Pheanstalk;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Pheanstalk\Command\CreateScheduleCommand;
8
use Pheanstalk\Command\GetWorkflowInstancesCommand;
9
use Pheanstalk\Structure\Schedule;
10
use Pheanstalk\Structure\TaskInstance;
11
use Pheanstalk\Structure\TimeSchedule;
12
use Pheanstalk\Structure\Tube;
13
use Pheanstalk\Structure\Workflow;
14
use Pheanstalk\Structure\WorkflowInstance;
15
use Pheanstalk\Structure\Job;
16
17
interface PheanstalkInterface
18
{
19
    const DEFAULT_PORT = 11300;
20
    const DEFAULT_DELAY = 0; // no delay
21
    const DEFAULT_PRIORITY = 1024; // most urgent: 0, least urgent: 4294967295
22
    const DEFAULT_TTR = 60; // 1 minute
23
    const DEFAULT_TUBE = 'default';
24
25
    /**
26
     * @param Connection
27
     *
28
     * @return $this
29
     */
30
    public function setConnection(Connection $connection);
31
32
    /**
33
     * The internal connection object.
34
     * Not required for general usage.
35
     *
36
     * @return Connection
37
     */
38
    public function getConnection();
39
40
    /**
41
     * @return PheanstalkInterface
42
     */
43
    public function setCurrentClass(PheanstalkInterface $currentClass): PheanstalkInterface;
44
45
    /**
46
     * @return PheanstalkInterface
47
     */
48
    public function getCurrentClass(): PheanstalkInterface;
49
50
    // ----------------------------------------
51
52
    /**
53
     * Permanently deletes a scheduled workflow.
54
     *
55
     * @param Schedule $schedule
56
     *
57
     * @return bool
58
     */
59
    public function deleteSchedule(Schedule $schedule);
60
61
    /**
62
     * Permanently deletes a job.
63
     *
64
     * @param Workflow $workflow
65
     *
66
     * @return bool
67
     */
68
    public function delete(Workflow $workflow);
69
70
//    /**
71
//     * Permanently deletes a tube.
72
//     *
73
//     * @param Tube $tube
74
//     *
75
//     * @return bool
76
//     */
77
//    public function deleteTube(Tube $tube);
78
79
    /**
80
     * Retrieve a workflow by its name, if there is no workflow named after
81
     * the arg given in the construct, returns false
82
     *
83
     * @param string $name The name of the workflow searched
84
     *
85
     * @return bool|Workflow If exists, the workflow
86
     */
87
    public function workflowExists($name);
88
89
    /**
90
     * Retrieve a workflow by its id, if there isn't for
91
     * the id given in the construct, returns false
92
     *
93
     * @param int $schedule The scheduled id researched
94
     *
95
     * @return Schedule If exists, the Schedule
96
     */
97
    public function getSchedule(int $schedule);
98
99
    /**
100
     * The Scheduled workflow.
101
     *
102
     * @return ArrayCollection[Schedule]
0 ignored issues
show
Documentation Bug introduced by
The doc comment ArrayCollection[Schedule] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
103
     */
104
    public function listSchedules();
105
106
    /**
107
     * Retrieve a workflow by its id, if there isn't for
108
     * the id given in the construct, returns false
109
     *
110
     * @param Workflow $workflow The workflow searched
111
     *
112
     * @return bool|Workflow If exists, the worflow
113
     */
114
    public function getWorkflow(Workflow $workflow);
115
116
    /**
117
     * Retrieve instances linked to a workflow
118
     *
119
     * @param null|Workflow $workflow The workflow we want the instances
120
     *
121
     * @return ArrayCollection
122
     */
123
    public function getWorkflowInstances(?Workflow $workflow, string $status = null);
124
125
    /**
126
     * Retrieve details of a workflowInstance
127
     *
128
     * @param null|Workflow $workflow The workflow we want the instances
129
     *
130
     * @return WorkflowInstance|false
131
     */
132
    public function getWorkflowInstancesDetails(WorkflowInstance $workflowInstance);
133
134
    /**
135
     * Retrieve a tube by its name, if there is no tube named after
136
     * the arg given in the construct, returns false
137
     *
138
     * @param string $name The name of the tube searched
139
     *
140
     * @return bool|Tube If exists, the workflow
141
     */
142
    public function tubeExists($name);
143
144
    /**
145
     * The names of all tubes on the server.
146
     *
147
     * @return ArrayCollection[Queue]
0 ignored issues
show
Documentation Bug introduced by
The doc comment ArrayCollection[Queue] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
148
     */
149
    public function listTubes();
150
151
    /**
152
     * Inspect a job in the system, regardless of what tube it is in.
153
     *
154
     * @return object Job
155
     */
156
    public function peek();
157
158
    /**
159
     * Puts a job on the queue.
160
     *
161
     * @param Workflow $workflow     The Workflow
162
     *
163
     * @return int The new job ID
164
     */
165
    public function put(Workflow $workflow);
166
167
    /**
168
     * Gives statistical information about the specified tube if it exists.
169
     *
170
     * @param Tube $tube
171
     *
172
     * @return object
173
     */
174
    public function statsTube(Tube $tube);
175
176
    /**
177
     * Gives statistical information about the beanstalkd system as a whole.
178
     *
179
     * @return object
180
     */
181
    public function stats();
182
183
    /**
184
     * Create a workflow on the queue.
185
     *
186
     * @param Workflow  $data     The workflow to create
187
     * @param null|bool (optional) $force Will erase already existent old workflow if already exists
0 ignored issues
show
The type Pheanstalk\optional was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
188
     *
189
     * @throws Exception\ClientException
190
     * @return Workflow The newly created workflow
191
     */
192
    public function create(Workflow $data, $force = false): Workflow;
193
194
    /**
195
     * Updates a Workflow.
196
     *
197
     * @param Workflow  $workflow     The workflow to update
198
     *
199
     * @return Workflow The updated workflow
200
     */
201
    public function update(Workflow $workflow): Workflow;
202
203
    /**
204
     * Updates a Schedule.
205
     *
206
     * @param Schedule  $schedule     The Schedule to update
207
     *
208
     * @return Schedule The updated Schedule
209
     */
210
    public function updateSchedule(Schedule $schedule): Schedule;
211
212
    /**
213
     * @param Schedule $schedule
214
     *
215
     * @return Schedule The workflow schedule
216
     */
217
    public function createSchedule(Schedule $schedule);
218
219
    /**
220
     * @param string        $name                   The name of the linked workflow
221
     * @param string        $group                  The group of the linked workflow
222
     * @param string        $path                   The command that will be executed by the workflow
223
     * @param null|string   $queue      (optional)  The queue of the workflow
224
     * @param bool          $useAgent   (optional)  Tell if you want to use the EvQueue Agent (Used to send status of tasks)
225
     * @param null|string   $user       (optional)  The user that will execute the command
226
     * @param null|string   $host       (optional)  The Ip address where to execute the command
227
     * @param null|string   $comment    (optional)  The comment of the workflow
228
     *
229
     * @return Workflow The newly created workflow
230
     */
231
    public function createTask(string $name, string $group, string $path, $queue = 'default', $useAgent = false, $user = null, $host = null, $comment = null): Workflow;
232
233
    /**
234
     * @param Tube $tube          The tube to create
235
     *
236
     * @throws Exception\ClientException
237
     * @return Tube
238
     */
239
    public function createTube(Tube $tube): Tube;
240
241
    /**
242
     * @param Tube $tube          The tube to update
243
     *
244
     * @throws Exception\ClientException
245
     * @return Tube
246
     */
247
    public function updateTube(Tube $tube): Tube;
248
249
    /**
250
     * Cancel a running workflow instance
251
     *
252
     * @param WorkflowInstance $workflowInstance
253
     * @throws Exception\ClientException
254
     * @return mixed
255
     */
256
    public function cancel(WorkflowInstance $workflowInstance);
257
258
    /**
259
     * Kills a running workflow instance
260
     *
261
     * @param WorkflowInstance $workflowInstance
262
     * @param TaskInstance $taskInstance
263
     * @throws Exception\ClientException
264
     * @return mixed
265
     */
266
    public function kill(WorkflowInstance $workflowInstance, TaskInstance $taskInstance);
267
}
268