-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGearmanClient.php
550 lines (464 loc) · 9.42 KB
/
GearmanClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
<?php
class GearmanClient
{
/* Constants */
const GEARMAN_SUCCESS = 0;
const GEARMAN_IO_WAIT = 1;
const GEARMAN_SHUTDOWN = 2;
const GEARMAN_SHUTDOWN_GRACEFUL = 3;
const GEARMAN_ERRNO = 4;
const GEARMAN_EVENT = 5;
const GEARMAN_TOO_MANY_ARGS = 6;
const GEARMAN_NO_ACTIVE_FDS = 7;
const GEARMAN_INVALID_MAGIC = 8;
const GEARMAN_INVALID_COMMAND = 9;
const GEARMAN_INVALID_PACKET = 10;
const GEARMAN_UNEXPECTED_PACKET = 11;
const GEARMAN_GETADDRINFO = 12;
const GEARMAN_NO_SERVERS = 13;
const GEARMAN_LOST_CONNECTION = 14;
const GEARMAN_MEMORY_ALLOCATION_FAILURE = 15;
const GEARMAN_JOB_EXISTS = 16;
const GEARMAN_JOB_QUEUE_FULL = 17;
const GEARMAN_SERVER_ERROR = 18;
const GEARMAN_WORK_ERROR = 19;
const GEARMAN_WORK_DATA = 20;
const GEARMAN_WORK_WARNING = 21;
const GEARMAN_WORK_STATUS = 22;
const GEARMAN_WORK_EXCEPTION = 23;
const GEARMAN_WORK_FAIL = 24;
const GEARMAN_NOT_CONNECTED = 25;
const GEARMAN_COULD_NOT_CONNECT = 26;
const GEARMAN_SEND_IN_PROGRESS = 27;
const GEARMAN_RECV_IN_PROGRESS = 28;
const GEARMAN_NOT_FLUSHING = 29;
const GEARMAN_DATA_TOO_LARGE = 30;
const GEARMAN_INVALID_FUNCTION_NAME = 31;
const GEARMAN_INVALID_WORKER_FUNCTION = 32;
const GEARMAN_NO_REGISTERED_FUNCTIONS = 33;
const GEARMAN_NO_JOBS = 34;
const GEARMAN_ECHO_DATA_CORRUPTION = 35;
const GEARMAN_NEED_WORKLOAD_FN = 36;
const GEARMAN_PAUSE = 37;
const GEARMAN_UNKNOWN_STATE = 38;
const GEARMAN_PTHREAD = 39;
const GEARMAN_PIPE_EOF = 40;
const GEARMAN_QUEUE_ERROR = 41;
const GEARMAN_FLUSH_DATA = 42;
const GEARMAN_SEND_BUFFER_TOO_SMALL = 43;
const GEARMAN_IGNORE_PACKET = 44;
const GEARMAN_UNKNOWN_OPTION = 45;
const GEARMAN_MAX_RETURN = 46;
/* Methods */
/**
* Add client options
*
* @param int $options The options to add
*
* @return bool Always returns TRUE.
*/
public function addOptions($options)
{
}
/**
* Add a job server to the client
*
* @param string $host
* @param int $port
*
* @return bool
*/
public function addServer($host = '127.0.0.1', $port = 4730)
{
}
/**
* Add a list of job servers to the client
*
* @param string $servers
*
* @return bool
*/
public function addServers($servers = '127.0.0.1:4730')
{
}
/**
* Add a task to be run in parallel
*
* @param string $function_name
* @param string $workload
* @param $context
* @param string $unique
*
* @return GearmanTask
*/
public function addTask($function_name, $workload, &$context, $unique)
{
}
/**
* Add a background task to be run in parallel
*
* @return GearmanTask
*/
public function addTaskBackground(string $function_name, string $workload, mixed &$context, string $unique)
{
}
/**
* Add a high priority task to run in parallel
*
* @return GearmanTask
*/
public function addTaskHigh(string $function_name, string $workload, mixed &$context, string $unique)
{
}
/**
* Add a high priority background task to be run in parallel
*
* @return GearmanTask
*/
public function addTaskHighBackground(string $function_name, string $workload, mixed &$context, string $unique)
{
}
/**
* Add a low priority task to run in parallel
*
* @return GearmanTask
*/
public function addTaskLow(string $function_name, string $workload, mixed &$context, string $unique)
{
}
/**
* Add a low priority background task to be run in parallel
*
* @return GearmanTask
*/
public function addTaskLowBackground(string $function_name, string $workload, mixed &$context, string $unique)
{
}
/**
* Add a task to get status
*
* @return GearmanTask
*/
public function addTaskStatus(string $job_handle, string &$context)
{
}
/**
* Clear all task callback functions
*
* @return bool
*/
public function clearCallbacks()
{
}
/**
* Create a copy of a GearmanClient object
*
* @return GearmanClient
*/
public function __clone()
{
}
/**
* Create a GearmanClient instance
*/
public function __construct()
{
}
/**
* Get the application context
*
* @return string
*/
public function context()
{
}
/**
* Get the application data (deprecated)
* @deprecated
*
* @return string
*/
public function data()
{
}
/**
* Run a single task and return a result
*
* @return string
*/
//REMOVED AS RESERVED WORD!!! public function do( string $function_name, string $workload, string $unique ){}
/**
* Run a task in the background
*
* @param string $function_name
* @param string $workload
* @param string $unique
*/
public function doBackground($function_name, $workload, $unique)
{
}
/**
* Run a single high priority task
*
* @param string $function_name
* @param string $workload
* @param string $unique
*
* @return string
*/
public function doHigh(string $function_name, string $workload, string $unique)
{
}
/**
* Run a high priority task in the background
*
* @param string $function_name
* @param string $workload
* @param string $unique
*
* @return string
*/
public function doHighBackground(string $function_name, string $workload, string $unique)
{
}
/**
* Get the job handle for the running task
*
* @return string
*/
public function doJobHandle()
{
}
/**
* Run a single low priority task
*
* @param string $function_name
* @param string $workload
* @param string $unique
*
* @return string
*/
public function doLow($function_name, $workload, $unique)
{
}
/**
* Run a low priority task in the background
*
* @param string $function_name
* @param string $workload
* @param string $unique
*
* @return string
*/
public function doLowBackground(string $function_name, string $workload, string $unique)
{
}
/**
* Get the status for the running task
*
* @return array
*/
public function doStatus()
{
}
/**
* Send data to all job servers to see if they echo it back
* //COMMENTED AS RESERVED WORD!!!
*/
// public function 'echo'() {
//
// }
/**
* Returns an error string for the last error encountered
*
* @return string
*/
public function error()
{
}
/**
* Get an errno value
*
* @return int
*/
public function getErrno()
{
}
/**
* Get the status of a background job
*
* @param string $job_handle
*
* @return array
*/
public function jobStatus($job_handle)
{
}
/**
* Remove client options
*
* @param int $options
*
* @return bool
*/
public function removeOptions($options)
{
}
/**
* Get the last Gearman return code
*
* @return int
*/
public function returnCode()
{
}
/**
* Run a list of tasks in parallel
*
* @return bool
*/
public function runTasks()
{
}
/**
* Callback function when there is a data packet for a task (deprecated)
*
* @deprecated
* @param callback $callback
*
* @return bool
*/
public function setClientCallback($callback)
{
}
/**
* Set a function to be called on task completion
*
* @param callback $callback
*
* @return bool
*/
public function setCompleteCallback($callback)
{
}
/**
* Set application context
*
* @param string $context
*
* @return bool
*/
public function setContext($context)
{
}
/**
* Set a callback for when a task is queued
*
* @param string $callback
*
* @return bool
*/
public function setCreatedCallback($callback)
{
}
/**
* Set application data (deprecated)
*
* @deprecated
*
* @param string $data
*
* @return bool
*/
public function setData($data)
{
}
/**
* Callback function when there is a data packet for a task
*
* @param callback $callback
*
* @return bool
*/
public function setDataCallback($callback)
{
}
/**
* Set a callback for worker exceptions
*
* @param callback $callback
*
* @return bool
*/
public function setExceptionCallback($callback)
{
}
/**
* Set callback for job failure
*
* @param callback $callback
*
* @return bool
*/
public function setFailCallback($callback)
{
}
/**
* Set client options
*
* @param int $options
*
* @return bool
*/
public function setOptions($options)
{
}
/**
* Set a callback for collecting task status
*
* @param callback $callback
*
* @return bool
*/
public function setStatusCallback($callback)
{
}
/**
* Set socket I/O activity timeout
*
* @param int $timeout
*
* @return bool
*/
public function setTimeout($timeout)
{
}
/**
* Set a callback for worker warnings
*
* @param callback $callback
*
* @return bool
*/
public function setWarningCallback($callback)
{
}
/**
* Set a callback for accepting incremental data updates
*
* @param callback $callback
*
* @return bool
*/
public function setWorkloadCallback($callback)
{
}
/**
* Get current socket I/O activity timeout value
*
* @return int
*/
public function timeout()
{
}
}