| 1 |
|
| MODULE = Punk::Queue PACKAGE = Punk::Queue::Backend |
| 2 |
|
| |
| 3 |
|
| # The shared backend surface. Both shipped backends inherit these; the |
| 4 |
|
| # per-driver divergences live in xs/backend_sqlite.xs (and, from phase 2, |
| 5 |
|
| # xs/backend_pg.xs). |
| 6 |
|
| # |
| 7 |
|
| # A hand-written backend is not required to inherit from this class - the |
| 8 |
|
| # contract is the method list, not the parentage. What it gets by |
| 9 |
|
| # inheriting is every method here for free. |
| 10 |
|
| |
| 11 |
|
| SV * |
| 12 |
|
| dbh(self) |
| 13 |
|
| SV *self |
| 14 |
|
| CODE: |
| 15 |
0 |
| RETVAL = newSVsv(pq_dbh(aTHX_ self)); |
| 16 |
|
| OUTPUT: |
| 17 |
|
| RETVAL |
| 18 |
|
| |
| 19 |
|
| IV |
| 20 |
|
| migrate(self, to = 0) |
| 21 |
|
| SV *self |
| 22 |
|
| IV to |
| 23 |
|
| CODE: |
| 24 |
0 |
| RETVAL = pq_migrate(aTHX_ self, to); |
| 25 |
|
| OUTPUT: |
| 26 |
|
| RETVAL |
| 27 |
|
| |
| 28 |
|
| IV |
| 29 |
|
| schema_version(self) |
| 30 |
|
| SV *self |
| 31 |
|
| CODE: |
| 32 |
0 |
| RETVAL = pq_schema_version(aTHX_ self); |
| 33 |
|
| OUTPUT: |
| 34 |
|
| RETVAL |
| 35 |
|
| |
| 36 |
|
| # The latest schema version this build knows how to apply, as opposed to |
| 37 |
|
| # the one the database is at. `punk-queue migrate --check` (phase 3) is the |
| 38 |
|
| # difference between the two. |
| 39 |
|
| IV |
| 40 |
|
| latest_version(self) |
| 41 |
|
| SV *self |
| 42 |
|
| CODE: |
| 43 |
4 |
| RETVAL = pq_migration_count(aTHX_ self); |
| 44 |
|
| OUTPUT: |
| 45 |
|
| RETVAL |
| 46 |
|
| |
| 47 |
|
| # now(), in the database's frame of reference: this host's clock plus the |
| 48 |
|
| # delta probed at connect. Every timestamp the dist binds comes from here. |
| 49 |
|
| NV |
| 50 |
|
| now(self) |
| 51 |
|
| SV *self |
| 52 |
|
| CODE: |
| 53 |
3 |
| RETVAL = pq_now(aTHX_ self); |
| 54 |
|
| OUTPUT: |
| 55 |
|
| RETVAL |
| 56 |
|
| |
| 57 |
|
| NV |
| 58 |
|
| clock_delta(self) |
| 59 |
|
| SV *self |
| 60 |
|
| PREINIT: |
| 61 |
|
| SV *d; |
| 62 |
|
| CODE: |
| 63 |
2 |
| (void)pq_dbh(aTHX_ self); |
| 64 |
2 |
| d = pq_get(aTHX_ pq_hv(aTHX_ self, "Punk::Queue::Backend"), |
| 65 |
|
| PQ_DELTA_KEY); |
| 66 |
2 |
▶ | RETVAL = d ? SvNV(d) : 0.0; |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = d ? SvNV(d) : 0.0; |
2 |
0 |
2 |
| RETVAL = d ? SvNV(d) : 0.0; |
0 |
2 |
2 |
|
| 67 |
|
| OUTPUT: |
| 68 |
|
| RETVAL |
| 69 |
|
| |
| 70 |
|
| IV |
| 71 |
|
| has_returning(self) |
| 72 |
|
| SV *self |
| 73 |
|
| CODE: |
| 74 |
0 |
▶ | RETVAL = pq_has_returning(aTHX_ self); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = pq_has_returning(aTHX_ self); |
0 |
0 |
0 |
|
| 75 |
|
| OUTPUT: |
| 76 |
|
| RETVAL |
| 77 |
|
| |
| 78 |
|
| IV |
| 79 |
|
| enqueue(self, task, args = NULL, opts = NULL) |
| 80 |
|
| SV *self |
| 81 |
|
| SV *task |
| 82 |
|
| SV *args |
| 83 |
|
| SV *opts |
| 84 |
|
| PREINIT: |
| 85 |
10 |
▶ | HV *o = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *o = NULL; |
0 |
10 |
10 |
|
| 86 |
|
| CODE: |
| 87 |
10 |
▶ | if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
0 |
10 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
0 |
10 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
0 |
10 |
|
| 88 |
10 |
| o = (HV *)SvRV(opts); |
| 89 |
10 |
| RETVAL = pq_enqueue(aTHX_ self, task, args, o); |
| 90 |
|
| OUTPUT: |
| 91 |
|
| RETVAL |
| 92 |
|
| |
| 93 |
|
| SV * |
| 94 |
|
| job_info(self, id) |
| 95 |
|
| SV *self |
| 96 |
|
| IV id |
| 97 |
|
| PREINIT: |
| 98 |
|
| SV *info; |
| 99 |
|
| CODE: |
| 100 |
0 |
| info = pq_job_info(aTHX_ self, id); |
| 101 |
0 |
▶ | if (!info) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!info) XSRETURN_UNDEF; |
0 |
0 |
0 |
|
| 102 |
0 |
| RETVAL = info; |
| 103 |
|
| OUTPUT: |
| 104 |
|
| RETVAL |
| 105 |
|
| |
| 106 |
|
| IV |
| 107 |
|
| finish_job(self, id, retries, result = NULL) |
| 108 |
|
| SV *self |
| 109 |
|
| IV id |
| 110 |
|
| IV retries |
| 111 |
|
| SV *result |
| 112 |
|
| CODE: |
| 113 |
0 |
| RETVAL = pq_finish_job(aTHX_ self, id, retries, result); |
| 114 |
|
| OUTPUT: |
| 115 |
|
| RETVAL |
| 116 |
|
| |
| 117 |
|
| IV |
| 118 |
|
| fail_job(self, id, retries, err = NULL) |
| 119 |
|
| SV *self |
| 120 |
|
| IV id |
| 121 |
|
| IV retries |
| 122 |
|
| SV *err |
| 123 |
|
| CODE: |
| 124 |
0 |
| RETVAL = pq_fail_job(aTHX_ self, id, retries, err); |
| 125 |
|
| OUTPUT: |
| 126 |
|
| RETVAL |
| 127 |
|
| |
| 128 |
|
| IV |
| 129 |
|
| retry_job(self, id, retries, opts = NULL) |
| 130 |
|
| SV *self |
| 131 |
|
| IV id |
| 132 |
|
| IV retries |
| 133 |
|
| SV *opts |
| 134 |
|
| PREINIT: |
| 135 |
0 |
▶ | HV *o = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *o = NULL; |
0 |
0 |
0 |
|
| 136 |
|
| CODE: |
| 137 |
0 |
▶ | if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 138 |
0 |
| o = (HV *)SvRV(opts); |
| 139 |
0 |
| RETVAL = pq_retry_job(aTHX_ self, id, retries, o); |
| 140 |
|
| OUTPUT: |
| 141 |
|
| RETVAL |
| 142 |
|
| |
| 143 |
|
| IV |
| 144 |
|
| remove_job(self, id) |
| 145 |
|
| SV *self |
| 146 |
|
| IV id |
| 147 |
|
| CODE: |
| 148 |
0 |
| RETVAL = pq_remove_job(aTHX_ self, id); |
| 149 |
|
| OUTPUT: |
| 150 |
|
| RETVAL |
| 151 |
|
| |
| 152 |
|
| IV |
| 153 |
|
| register_worker(self, id = 0, opts = NULL) |
| 154 |
|
| SV *self |
| 155 |
|
| IV id |
| 156 |
|
| SV *opts |
| 157 |
|
| PREINIT: |
| 158 |
11 |
▶ | HV *o = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *o = NULL; |
11 |
0 |
11 |
|
| 159 |
|
| CODE: |
| 160 |
11 |
▶ | if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
1 |
11 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
0 |
10 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
10 |
0 |
10 |
|
| 161 |
10 |
| o = (HV *)SvRV(opts); |
| 162 |
11 |
| RETVAL = pq_register_worker(aTHX_ self, id, o); |
| 163 |
|
| OUTPUT: |
| 164 |
|
| RETVAL |
| 165 |
|
| |
| 166 |
|
| IV |
| 167 |
|
| unregister_worker(self, id) |
| 168 |
|
| SV *self |
| 169 |
|
| IV id |
| 170 |
|
| CODE: |
| 171 |
35 |
| RETVAL = pq_unregister_worker(aTHX_ self, id); |
| 172 |
|
| OUTPUT: |
| 173 |
|
| RETVAL |
| 174 |
|
| |
| 175 |
|
| IV |
| 176 |
|
| worker_heartbeat(self, id, status = NULL) |
| 177 |
|
| SV *self |
| 178 |
|
| IV id |
| 179 |
|
| SV *status |
| 180 |
|
| CODE: |
| 181 |
29 |
| RETVAL = pq_worker_heartbeat(aTHX_ self, id, status); |
| 182 |
|
| OUTPUT: |
| 183 |
|
| RETVAL |
| 184 |
|
| |
| 185 |
|
| SV * |
| 186 |
|
| list_jobs(self, offset = 0, limit = 0, filter = NULL, sort_col = NULL, sort_dir = NULL) |
| 187 |
|
| SV *self |
| 188 |
|
| IV offset |
| 189 |
|
| IV limit |
| 190 |
|
| SV *filter |
| 191 |
|
| SV *sort_col |
| 192 |
|
| SV *sort_dir |
| 193 |
|
| PREINIT: |
| 194 |
0 |
▶ | HV *f = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *f = NULL; |
0 |
0 |
0 |
|
| 195 |
|
| CODE: |
| 196 |
0 |
▶ | if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 197 |
0 |
| f = (HV *)SvRV(filter); |
| 198 |
0 |
| RETVAL = pq_list_jobs(aTHX_ self, offset, limit, f, sort_col, sort_dir); |
| 199 |
|
| OUTPUT: |
| 200 |
|
| RETVAL |
| 201 |
|
| |
| 202 |
|
| SV * |
| 203 |
|
| list_workers(self, offset = 0, limit = 0, filter = NULL) |
| 204 |
|
| SV *self |
| 205 |
|
| IV offset |
| 206 |
|
| IV limit |
| 207 |
|
| SV *filter |
| 208 |
|
| PREINIT: |
| 209 |
0 |
▶ | HV *f = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *f = NULL; |
0 |
0 |
0 |
|
| 210 |
|
| CODE: |
| 211 |
0 |
▶ | if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 212 |
0 |
| f = (HV *)SvRV(filter); |
| 213 |
0 |
| RETVAL = pq_list_workers(aTHX_ self, offset, limit, f); |
| 214 |
|
| OUTPUT: |
| 215 |
|
| RETVAL |
| 216 |
|
| |
| 217 |
|
| SV * |
| 218 |
|
| stats(self) |
| 219 |
|
| SV *self |
| 220 |
|
| CODE: |
| 221 |
0 |
| RETVAL = pq_stats(aTHX_ self); |
| 222 |
|
| OUTPUT: |
| 223 |
|
| RETVAL |
| 224 |
|
| |
| 225 |
|
| # Merge into a job's notes; a key whose value is undef is deleted. Works |
| 226 |
|
| # in any state - progress notes on an active job are the whole point. |
| 227 |
|
| IV |
| 228 |
|
| note(self, id, merge) |
| 229 |
|
| SV *self |
| 230 |
|
| IV id |
| 231 |
|
| SV *merge |
| 232 |
|
| PREINIT: |
| 233 |
3 |
▶ | HV *m = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *m = NULL; |
3 |
0 |
3 |
|
| 234 |
|
| CODE: |
| 235 |
3 |
▶ | if (merge && SvROK(merge) && SvTYPE(SvRV(merge)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (merge && SvROK(merge) && SvTYPE(SvRV(merge)) == SVt_PVHV) |
3 |
0 |
3 |
| if (merge && SvROK(merge) && SvTYPE(SvRV(merge)) == SVt_PVHV) |
3 |
0 |
3 |
| if (merge && SvROK(merge) && SvTYPE(SvRV(merge)) == SVt_PVHV) |
3 |
0 |
3 |
|
| 236 |
3 |
| m = (HV *)SvRV(merge); |
| 237 |
3 |
▶ | if (!m) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!m) |
0 |
3 |
3 |
|
| 238 |
0 |
| croak("Punk::Queue: note needs a hash reference to merge"); |
| 239 |
3 |
| RETVAL = pq_note(aTHX_ self, id, m); |
| 240 |
|
| OUTPUT: |
| 241 |
|
| RETVAL |
| 242 |
|
| |
| 243 |
|
| # Append one log line to a job. Always writes - the `logging` option |
| 244 |
|
| # gates only the automatic lifecycle rows. |
| 245 |
|
| |
| 246 |
|
| IV |
| 247 |
|
| log_job(self, id, message, level = NULL) |
| 248 |
|
| SV *self |
| 249 |
|
| IV id |
| 250 |
|
| SV *message |
| 251 |
|
| SV *level |
| 252 |
|
| CODE: |
| 253 |
2 |
▶ | pq_log_add(aTHX_ self, id, level && SvOK(level) |
Branch: 2 branches
| Branch | True | False | Total |
| pq_log_add(aTHX_ self, id, level && SvOK(level) |
1 |
0 |
1 |
| pq_log_add(aTHX_ self, id, level && SvOK(level) |
1 |
0 |
1 |
|
| 254 |
1 |
| ? SvPV_nolen(level) : NULL, message); |
| 255 |
0 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
0 |
0 |
|
| 256 |
|
| OUTPUT: |
| 257 |
|
| RETVAL |
| 258 |
|
| |
| 259 |
|
| # The whole log for one job, oldest first: |
| 260 |
|
| # [ { created, level, message }, ... ] |
| 261 |
|
| |
| 262 |
|
| SV * |
| 263 |
|
| job_log(self, id) |
| 264 |
|
| SV *self |
| 265 |
|
| IV id |
| 266 |
|
| CODE: |
| 267 |
0 |
| RETVAL = newRV_noinc((SV *)pq_job_log_rows(aTHX_ self, id)); |
| 268 |
|
| OUTPUT: |
| 269 |
|
| RETVAL |
| 270 |
|
| |
| 271 |
|
| void |
| 272 |
|
| reset(self) |
| 273 |
|
| SV *self |
| 274 |
|
| CODE: |
| 275 |
0 |
| pq_reset(aTHX_ self); |
| 276 |
|
| |
| 277 |
|
| # ---- locks ------------------------------------------------------------------ |
| 278 |
|
| |
| 279 |
|
| IV |
| 280 |
|
| lock(self, name, duration, opts = NULL) |
| 281 |
|
| SV *self |
| 282 |
|
| SV *name |
| 283 |
|
| NV duration |
| 284 |
|
| SV *opts |
| 285 |
|
| PREINIT: |
| 286 |
14 |
| HV *o = NULL; |
| 287 |
|
| SV *v; |
| 288 |
14 |
▶ | IV limit = 1, owner = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| IV limit = 1, owner = 0; |
0 |
14 |
14 |
|
| 289 |
|
| CODE: |
| 290 |
14 |
▶ | if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
14 |
0 |
14 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
14 |
0 |
14 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
14 |
0 |
14 |
|
| 291 |
14 |
| o = (HV *)SvRV(opts); |
| 292 |
14 |
▶ | if (o && (v = pq_get(aTHX_ o, "limit")) && SvOK(v)) limit = SvIV(v); |
Branch: 3 branches
| Branch | True | False | Total |
| if (o && (v = pq_get(aTHX_ o, "limit")) && SvOK(v)) limit = SvIV(v); |
14 |
0 |
14 |
| if (o && (v = pq_get(aTHX_ o, "limit")) && SvOK(v)) limit = SvIV(v); |
0 |
14 |
14 |
| if (o && (v = pq_get(aTHX_ o, "limit")) && SvOK(v)) limit = SvIV(v); |
0 |
0 |
0 |
|
| 293 |
14 |
▶ | if (o && (v = pq_get(aTHX_ o, "owner")) && SvOK(v)) owner = SvIV(v); |
Branch: 3 branches
| Branch | True | False | Total |
| if (o && (v = pq_get(aTHX_ o, "owner")) && SvOK(v)) owner = SvIV(v); |
14 |
0 |
14 |
| if (o && (v = pq_get(aTHX_ o, "owner")) && SvOK(v)) owner = SvIV(v); |
14 |
0 |
14 |
| if (o && (v = pq_get(aTHX_ o, "owner")) && SvOK(v)) owner = SvIV(v); |
14 |
0 |
14 |
|
| 294 |
14 |
| RETVAL = pq_lock(aTHX_ self, name, duration, limit, owner); |
| 295 |
|
| OUTPUT: |
| 296 |
|
| RETVAL |
| 297 |
|
| |
| 298 |
|
| IV |
| 299 |
|
| renew_lock(self, name, owner, duration) |
| 300 |
|
| SV *self |
| 301 |
|
| SV *name |
| 302 |
|
| IV owner |
| 303 |
|
| NV duration |
| 304 |
|
| CODE: |
| 305 |
3 |
| RETVAL = pq_renew_lock(aTHX_ self, name, owner, duration); |
| 306 |
|
| OUTPUT: |
| 307 |
|
| RETVAL |
| 308 |
|
| |
| 309 |
|
| IV |
| 310 |
|
| unlock(self, name, owner = NULL) |
| 311 |
|
| SV *self |
| 312 |
|
| SV *name |
| 313 |
|
| SV *owner |
| 314 |
|
| CODE: |
| 315 |
39 |
▶ | RETVAL = pq_unlock(aTHX_ self, name, |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = pq_unlock(aTHX_ self, name, |
13 |
0 |
13 |
| RETVAL = pq_unlock(aTHX_ self, name, |
13 |
0 |
13 |
|
| 316 |
13 |
▶ | (owner && SvOK(owner)) ? SvIV(owner) : 0, |
Branch: 1 branch
| Branch | True | False | Total |
| (owner && SvOK(owner)) ? SvIV(owner) : 0, |
13 |
0 |
13 |
|
| 317 |
13 |
▶ | (owner && SvOK(owner)) ? 1 : 0); |
Branch: 1 branch
| Branch | True | False | Total |
| (owner && SvOK(owner)) ? 1 : 0); |
13 |
0 |
13 |
|
| 318 |
|
| OUTPUT: |
| 319 |
|
| RETVAL |
| 320 |
|
| |
| 321 |
|
| SV * |
| 322 |
|
| list_locks(self, offset = 0, limit = 0, filter = NULL) |
| 323 |
|
| SV *self |
| 324 |
|
| IV offset |
| 325 |
|
| IV limit |
| 326 |
|
| SV *filter |
| 327 |
|
| PREINIT: |
| 328 |
0 |
▶ | HV *f = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *f = NULL; |
0 |
0 |
0 |
|
| 329 |
|
| CODE: |
| 330 |
0 |
▶ | if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
| if (filter && SvROK(filter) && SvTYPE(SvRV(filter)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 331 |
0 |
| f = (HV *)SvRV(filter); |
| 332 |
0 |
| RETVAL = pq_list_locks(aTHX_ self, offset, limit, f); |
| 333 |
|
| OUTPUT: |
| 334 |
|
| RETVAL |
| 335 |
|
| |
| 336 |
|
| # ---- broadcast / receive ---------------------------------------------------- |
| 337 |
|
| |
| 338 |
|
| IV |
| 339 |
|
| broadcast(self, cmd, args = NULL, ids = NULL) |
| 340 |
|
| SV *self |
| 341 |
|
| SV *cmd |
| 342 |
|
| SV *args |
| 343 |
|
| SV *ids |
| 344 |
|
| PREINIT: |
| 345 |
0 |
▶ | AV *a = NULL, *w = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| AV *a = NULL, *w = NULL; |
0 |
0 |
0 |
|
| 346 |
|
| CODE: |
| 347 |
0 |
▶ | if (args && SvROK(args) && SvTYPE(SvRV(args)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (args && SvROK(args) && SvTYPE(SvRV(args)) == SVt_PVAV) |
0 |
0 |
0 |
| if (args && SvROK(args) && SvTYPE(SvRV(args)) == SVt_PVAV) |
0 |
0 |
0 |
| if (args && SvROK(args) && SvTYPE(SvRV(args)) == SVt_PVAV) |
0 |
0 |
0 |
|
| 348 |
0 |
| a = (AV *)SvRV(args); |
| 349 |
0 |
▶ | if (ids && SvROK(ids) && SvTYPE(SvRV(ids)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ids && SvROK(ids) && SvTYPE(SvRV(ids)) == SVt_PVAV) |
0 |
0 |
0 |
| if (ids && SvROK(ids) && SvTYPE(SvRV(ids)) == SVt_PVAV) |
0 |
0 |
0 |
| if (ids && SvROK(ids) && SvTYPE(SvRV(ids)) == SVt_PVAV) |
0 |
0 |
0 |
|
| 350 |
0 |
| w = (AV *)SvRV(ids); |
| 351 |
0 |
| RETVAL = pq_broadcast(aTHX_ self, cmd, a, w); |
| 352 |
|
| OUTPUT: |
| 353 |
|
| RETVAL |
| 354 |
|
| |
| 355 |
|
| SV * |
| 356 |
|
| receive(self, worker_id) |
| 357 |
|
| SV *self |
| 358 |
|
| IV worker_id |
| 359 |
|
| CODE: |
| 360 |
13 |
| RETVAL = pq_receive(aTHX_ self, worker_id); |
| 361 |
|
| OUTPUT: |
| 362 |
|
| RETVAL |
| 363 |
|
| |
| 364 |
|
| # ---- repair and history ----------------------------------------------------- |
| 365 |
|
| |
| 366 |
|
| SV * |
| 367 |
|
| repair(self, opts = NULL) |
| 368 |
|
| SV *self |
| 369 |
|
| SV *opts |
| 370 |
|
| PREINIT: |
| 371 |
0 |
| HV *o = NULL; |
| 372 |
|
| SV *v; |
| 373 |
0 |
▶ | int deep = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| int deep = 0; |
0 |
0 |
0 |
|
| 374 |
|
| CODE: |
| 375 |
0 |
▶ | if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
| if (opts && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 376 |
0 |
| o = (HV *)SvRV(opts); |
| 377 |
0 |
▶ | if (o && (v = pq_get(aTHX_ o, "deep")) && SvTRUE(v)) deep = 1; |
Branch: 3 branches
| Branch | True | False | Total |
| if (o && (v = pq_get(aTHX_ o, "deep")) && SvTRUE(v)) deep = 1; |
0 |
0 |
0 |
| if (o && (v = pq_get(aTHX_ o, "deep")) && SvTRUE(v)) deep = 1; |
0 |
0 |
0 |
| if (o && (v = pq_get(aTHX_ o, "deep")) && SvTRUE(v)) deep = 1; |
0 |
0 |
0 |
|
| 378 |
0 |
| RETVAL = pq_repair(aTHX_ self, deep); |
| 379 |
|
| OUTPUT: |
| 380 |
|
| RETVAL |
| 381 |
|
| |
| 382 |
|
| SV * |
| 383 |
|
| history(self) |
| 384 |
|
| SV *self |
| 385 |
|
| CODE: |
| 386 |
0 |
| RETVAL = pq_history(aTHX_ self); |
| 387 |
|
| OUTPUT: |
| 388 |
|
| RETVAL |
| 389 |
|
| |
| 390 |
|
| # Seconds until the next delayed job in these queues becomes claimable, |
| 391 |
|
| # or undef when none is waiting. The worker's sleep clamp; called with |
| 392 |
|
| # G_EVAL from C, hence a method. |
| 393 |
|
| SV * |
| 394 |
|
| _ready_horizon(self, queues) |
| 395 |
|
| SV *self |
| 396 |
|
| SV *queues |
| 397 |
|
| PREINIT: |
| 398 |
|
| AV *q; |
| 399 |
|
| double h; |
| 400 |
|
| CODE: |
| 401 |
15 |
| q = pq_sql_list(aTHX_ queues); |
| 402 |
15 |
▶ | if (av_len(q) < 0) av_push(q, newSVpvs("default")); |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(q) < 0) av_push(q, newSVpvs("default")); |
0 |
15 |
15 |
|
| 403 |
15 |
| h = pq_ready_horizon(aTHX_ self, q); |
| 404 |
15 |
▶ | if (h < 0) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (h < 0) XSRETURN_UNDEF; |
15 |
0 |
15 |
|
| 405 |
0 |
| RETVAL = newSVnv(h); |
| 406 |
|
| OUTPUT: |
| 407 |
|
| RETVAL |
| 408 |
|
| |
| 409 |
|
| # ---- cron storage ----------------------------------------------------------- |
| 410 |
|
| |
| 411 |
|
| IV |
| 412 |
|
| upsert_cron(self, def) |
| 413 |
|
| SV *self |
| 414 |
|
| SV *def |
| 415 |
|
| PREINIT: |
| 416 |
0 |
▶ | HV *d = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *d = NULL; |
0 |
0 |
0 |
|
| 417 |
|
| CODE: |
| 418 |
0 |
▶ | if (def && SvROK(def) && SvTYPE(SvRV(def)) == SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (def && SvROK(def) && SvTYPE(SvRV(def)) == SVt_PVHV) |
0 |
0 |
0 |
| if (def && SvROK(def) && SvTYPE(SvRV(def)) == SVt_PVHV) |
0 |
0 |
0 |
| if (def && SvROK(def) && SvTYPE(SvRV(def)) == SVt_PVHV) |
0 |
0 |
0 |
|
| 419 |
0 |
| d = (HV *)SvRV(def); |
| 420 |
0 |
▶ | if (!d) croak("Punk::Queue: upsert_cron needs a hash reference"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!d) croak("Punk::Queue: upsert_cron needs a hash reference"); |
0 |
0 |
0 |
|
| 421 |
0 |
| RETVAL = pq_upsert_cron(aTHX_ self, d); |
| 422 |
|
| OUTPUT: |
| 423 |
|
| RETVAL |
| 424 |
|
| |
| 425 |
|
| IV |
| 426 |
|
| disable_missing_crons(self, names = NULL) |
| 427 |
|
| SV *self |
| 428 |
|
| SV *names |
| 429 |
|
| PREINIT: |
| 430 |
0 |
▶ | AV *n = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| AV *n = NULL; |
0 |
0 |
0 |
|
| 431 |
|
| CODE: |
| 432 |
0 |
▶ | if (names && SvROK(names) && SvTYPE(SvRV(names)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (names && SvROK(names) && SvTYPE(SvRV(names)) == SVt_PVAV) |
0 |
0 |
0 |
| if (names && SvROK(names) && SvTYPE(SvRV(names)) == SVt_PVAV) |
0 |
0 |
0 |
| if (names && SvROK(names) && SvTYPE(SvRV(names)) == SVt_PVAV) |
0 |
0 |
0 |
|
| 433 |
0 |
| n = (AV *)SvRV(names); |
| 434 |
0 |
| RETVAL = pq_disable_missing_crons(aTHX_ self, n); |
| 435 |
|
| OUTPUT: |
| 436 |
|
| RETVAL |
| 437 |
|
| |
| 438 |
|
| IV |
| 439 |
|
| enable_cron(self, name, on = 1) |
| 440 |
|
| SV *self |
| 441 |
|
| SV *name |
| 442 |
|
| IV on |
| 443 |
|
| CODE: |
| 444 |
0 |
| RETVAL = pq_enable_cron(aTHX_ self, name, on ? 1 : 0); |
| 445 |
|
| OUTPUT: |
| 446 |
|
| RETVAL |
| 447 |
|
| |
| 448 |
|
| SV * |
| 449 |
|
| cron_info(self, name) |
| 450 |
|
| SV *self |
| 451 |
|
| SV *name |
| 452 |
|
| PREINIT: |
| 453 |
|
| SV *info; |
| 454 |
|
| CODE: |
| 455 |
0 |
| info = pq_cron_info(aTHX_ self, name); |
| 456 |
0 |
▶ | if (!info) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!info) XSRETURN_UNDEF; |
0 |
0 |
0 |
|
| 457 |
0 |
| RETVAL = info; |
| 458 |
|
| OUTPUT: |
| 459 |
|
| RETVAL |
| 460 |
|
| |
| 461 |
|
| SV * |
| 462 |
|
| list_crons(self, offset = 0, limit = 0) |
| 463 |
|
| SV *self |
| 464 |
|
| IV offset |
| 465 |
|
| IV limit |
| 466 |
|
| CODE: |
| 467 |
0 |
| RETVAL = pq_list_crons(aTHX_ self, offset, limit); |
| 468 |
|
| OUTPUT: |
| 469 |
|
| RETVAL |
| 470 |
|
| |
| 471 |
|
| # One leader tick: fire every due cron per its catch-up policy. The |
| 472 |
|
| # caller holds the pq.cron.leader lease; the optimistic guard and the |
| 473 |
|
| # occurrence dedupe make a stale caller harmless anyway. |
| 474 |
|
| IV |
| 475 |
|
| _cron_tick(self, limit = 100) |
| 476 |
|
| SV *self |
| 477 |
|
| IV limit |
| 478 |
|
| CODE: |
| 479 |
26 |
| RETVAL = pq_cron_tick(aTHX_ self, limit); |
| 480 |
|
| OUTPUT: |
| 481 |
|
| RETVAL |