From b96e07cf88bf40dd586461020637b92b0848caf9 Mon Sep 17 00:00:00 2001 From: rkhapov Date: Sun, 3 Nov 2024 12:20:15 +0500 Subject: [PATCH] wip Signed-off-by: rkhapov --- sources/console.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sources/console.c b/sources/console.c index dba1fc52..e6dc55d6 100644 --- a/sources/console.c +++ b/sources/console.c @@ -33,6 +33,7 @@ typedef enum { OD_LVERSION, OD_LLISTEN, OD_LSTORAGES, + OD_LWORKER_QUEUE_SIZES, } od_console_keywords_t; static od_keyword_t od_console_keywords[] = { @@ -59,6 +60,7 @@ static od_keyword_t od_console_keywords[] = { od_keyword("version", OD_LVERSION), od_keyword("listen", OD_LLISTEN), od_keyword("storages", OD_LSTORAGES), + od_keyword("worker_queue_sizes", OD_LWORKER_QUEUE_SIZES), { 0, 0, 0 } }; @@ -563,6 +565,27 @@ od_console_show_quantiles(machine_msg_t *stream, int offset, return rc; } +static inline od_retcode_t +od_console_show_worker_queue_sizes(od_client_t *client, machine_msg_t *stream) +{ + od_global_t *global = client->global; + od_worker_pool_t *worker_pool = global->worker_pool; + + if (kiwi_be_write_row_descriptionf(stream, "ll", "worker_id", + "queue_size") == NULL) { + return NOT_OK_RESPONSE; + } + + for (uint32_t i = 0; i < worker_pool->count; ++i) { + od_worker_t *worker = &worker_pool->pool[i]; + + (void)worker->id; + (void)machine_channel_ready_count(worker->task_channel); + } + + return kiwi_be_write_complete(stream, "SHOW", 5); +} + static inline int od_console_show_pools_add_cb(od_route_t *route, void **argv) { int offset; @@ -1778,6 +1801,8 @@ static inline int od_console_show(od_client_t *client, machine_msg_t *stream, return od_console_show_listen(client, stream); case OD_LSTORAGES: return od_console_show_storages(client, stream); + case OD_LWORKER_QUEUE_SIZES: + return od_console_show_worker_queue_sizes(client, stream); } return NOT_OK_RESPONSE; }