|
| 1 | +version: 77 |
| 2 | +description: create additional functions to filter workers on state and quarantined status |
| 3 | +methods: |
| 4 | + get_queue_workers_with_wm_join_state: |
| 5 | + description: |- |
| 6 | + Get non-expired queue workers by state ordered by worker_pool_id, worker_group, and worker_id. |
| 7 | + Workers are not considered expired until after their quarantine date expires. |
| 8 | + If the pagination arguments are both NULL, all rows are returned. |
| 9 | + Otherwise, page_size rows are returned at offset page_offset. |
| 10 | + This also performs an outer join with the worker_manager.worker table for more data. |
| 11 | + mode: read |
| 12 | + serviceName: worker_manager |
| 13 | + args: task_queue_id_in text, expires_in timestamptz, page_size_in integer, page_offset_in integer, worker_state_in text |
| 14 | + returns: table(worker_pool_id text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, last_date_active timestamptz, state text, capacity int4, provider_id text, etag uuid) |
| 15 | + body: |- |
| 16 | + begin |
| 17 | + return query |
| 18 | + select |
| 19 | + queue_workers.task_queue_id as worker_pool_id, |
| 20 | + queue_workers.worker_group, |
| 21 | + queue_workers.worker_id, |
| 22 | + queue_workers.quarantine_until, |
| 23 | + queue_workers.expires, |
| 24 | + queue_workers.first_claim, |
| 25 | + queue_workers.recent_tasks, |
| 26 | + queue_workers.last_date_active, |
| 27 | + workers.state, |
| 28 | + workers.capacity, |
| 29 | + workers.provider_id, |
| 30 | + public.gen_random_uuid() |
| 31 | + from queue_workers |
| 32 | + full outer join workers on workers.worker_id = queue_workers.worker_id |
| 33 | + where |
| 34 | + workers.state = worker_state_in and |
| 35 | + (queue_workers.task_queue_id = task_queue_id_in or get_queue_workers_with_wm_join_state.task_queue_id_in is null) and |
| 36 | + ((queue_workers.expires > expires_in and queue_workers.quarantine_until < expires_in) or get_queue_workers_with_wm_join_state.expires_in is null) |
| 37 | + order by worker_pool_id, worker_group, worker_id |
| 38 | + limit get_page_limit(page_size_in) |
| 39 | + offset get_page_offset(page_offset_in); |
| 40 | + end |
| 41 | + get_queue_workers_with_wm_join_quarantined: |
| 42 | + description: |- |
| 43 | + Get quarantined queue workers ordered by worker_pool_id, worker_group, and worker_id. |
| 44 | + If the pagination arguments are both NULL, all rows are returned. |
| 45 | + Otherwise, page_size rows are returned at offset page_offset. |
| 46 | + This also performs an outer join with the worker_manager.worker table for more data. |
| 47 | + mode: read |
| 48 | + serviceName: worker_manager |
| 49 | + args: task_queue_id_in text, page_size_in integer, page_offset_in integer |
| 50 | + returns: table(worker_pool_id text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, last_date_active timestamptz, state text, capacity int4, provider_id text, etag uuid) |
| 51 | + body: |- |
| 52 | + begin |
| 53 | + return query |
| 54 | + select |
| 55 | + queue_workers.task_queue_id as worker_pool_id, |
| 56 | + queue_workers.worker_group, |
| 57 | + queue_workers.worker_id, |
| 58 | + queue_workers.quarantine_until, |
| 59 | + queue_workers.expires, |
| 60 | + queue_workers.first_claim, |
| 61 | + queue_workers.recent_tasks, |
| 62 | + queue_workers.last_date_active, |
| 63 | + workers.state, |
| 64 | + workers.capacity, |
| 65 | + workers.provider_id, |
| 66 | + public.gen_random_uuid() |
| 67 | + from queue_workers |
| 68 | + full outer join workers on workers.worker_id = queue_workers.worker_id |
| 69 | + where |
| 70 | + (queue_workers.task_queue_id = task_queue_id_in or get_queue_workers_with_wm_join_quarantined.task_queue_id_in is null) and |
| 71 | + (queue_workers.expires >= now() and queue_workers.quarantine_until >= now()) |
| 72 | + order by worker_pool_id, worker_group, worker_id |
| 73 | + limit get_page_limit(page_size_in) |
| 74 | + offset get_page_offset(page_offset_in); |
| 75 | + end |
0 commit comments