1 | <?php |
||
25 | class JobClass implements ContainerAwareInterface |
||
26 | { |
||
27 | use ContainerAwareTrait; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | * |
||
32 | * Default description when is not defined |
||
33 | */ |
||
34 | const DEFAULT_DESCRIPTION = 'No description is defined'; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | * |
||
39 | * Callable name for this job |
||
40 | * If is setted on annotations, this value will be used |
||
41 | * otherwise, natural method name will be used. |
||
42 | */ |
||
43 | private $callableName; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | * |
||
48 | * Method name |
||
49 | */ |
||
50 | private $methodName; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | * |
||
55 | * RealCallable name for this job without the job prefix |
||
56 | * |
||
57 | */ |
||
58 | private $realCallableNameNoPrefix; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | * |
||
63 | * RealCallable name for this job |
||
64 | * natural method name will be used. |
||
65 | */ |
||
66 | private $realCallableName; |
||
67 | |||
68 | /** |
||
69 | * @var string |
||
70 | * |
||
71 | * Description of Job |
||
72 | */ |
||
73 | private $description; |
||
74 | |||
75 | /** |
||
76 | * @var integer |
||
77 | * |
||
78 | * Number of iterations this job will be alive before die |
||
79 | */ |
||
80 | private $iterations; |
||
81 | |||
82 | /** |
||
83 | * @var string |
||
84 | * |
||
85 | * Default method this job will be call into Gearman client |
||
86 | */ |
||
87 | private $defaultMethod; |
||
88 | |||
89 | /** |
||
90 | * @var int |
||
91 | * |
||
92 | * Job minimum execution time |
||
93 | */ |
||
94 | private $minimumExecutionTime; |
||
95 | |||
96 | /** |
||
97 | * @var int |
||
98 | * |
||
99 | * Timeout for idle worker |
||
100 | */ |
||
101 | private $timeout; |
||
102 | |||
103 | /** |
||
104 | * @var array |
||
105 | * |
||
106 | * Collection of servers to connect |
||
107 | */ |
||
108 | private $servers; |
||
109 | |||
110 | /** |
||
111 | * @var string |
||
112 | * |
||
113 | * The prefix to be prepended to all job callable names. |
||
114 | */ |
||
115 | private $jobPrefix; |
||
116 | |||
117 | /** |
||
118 | * Construct method |
||
119 | * |
||
120 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
121 | * @param \ReflectionMethod $reflectionMethod ReflextionMethod class |
||
122 | * @param string $callableNameClass Callable name class |
||
123 | * @param array $servers Array of servers defined for Worker |
||
124 | * @param array $defaultSettings Default settings for Worker |
||
125 | */ |
||
126 | 6 | public function __construct( |
|
159 | |||
160 | /** |
||
161 | * Load servers |
||
162 | * |
||
163 | * If any server is defined in JobAnnotation, this one is used. |
||
164 | * Otherwise is used servers set in Class |
||
165 | * |
||
166 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
167 | * @param array $servers Array of servers defined for Worker |
||
168 | * |
||
169 | * @return array Servers |
||
170 | */ |
||
171 | 6 | private function loadServers(JobAnnotation $jobAnnotation, array $servers) |
|
186 | |||
187 | /** |
||
188 | * Load iterations |
||
189 | * |
||
190 | * If iterations is defined in JobAnnotation, this one is used. |
||
191 | * Otherwise is used set in Class |
||
192 | * |
||
193 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
194 | * @param array $defaultSettings Default settings for Worker |
||
195 | * |
||
196 | * @return integer Iteration |
||
197 | */ |
||
198 | 6 | private function loadIterations(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
204 | |||
205 | /** |
||
206 | * Load defaultMethod |
||
207 | * |
||
208 | * If defaultMethod is defined in JobAnnotation, this one is used. |
||
209 | * Otherwise is used set in Class |
||
210 | * |
||
211 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
212 | * @param array $defaultSettings Default settings for Worker |
||
213 | * |
||
214 | * @return string Default method |
||
215 | */ |
||
216 | 6 | private function loadDefaultMethod(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
222 | |||
223 | /** |
||
224 | * Load minimumExecutionTime |
||
225 | * |
||
226 | * If minimumExecutionTime is defined in JobAnnotation, this one is used. |
||
227 | * Otherwise is used set in Class |
||
228 | * |
||
229 | * @param JobAnnotation $jobAnnotation |
||
230 | * @param array $defaultSettings |
||
231 | * |
||
232 | * @return int |
||
233 | */ |
||
234 | 6 | private function loadMinimumExecutionTime(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
240 | |||
241 | /** |
||
242 | * Load timeout |
||
243 | * |
||
244 | * If timeout is defined in JobAnnotation, this one is used. |
||
245 | * Otherwise is used set in Class |
||
246 | * |
||
247 | * @param JobAnnotation $jobAnnotation |
||
248 | * @param array $defaultSettings |
||
249 | * |
||
250 | * @return int |
||
251 | */ |
||
252 | 6 | private function loadTimeout(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
258 | |||
259 | /** |
||
260 | * Retrieve all Job data in cache format |
||
261 | * |
||
262 | * @return array |
||
263 | */ |
||
264 | 6 | public function toArray() |
|
281 | } |
||
282 |