]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua_fcn: add Server.get_pend_conn() and Server.get_cur_sess()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 3 Apr 2023 08:43:17 +0000 (10:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 14:28:32 +0000 (16:28 +0200)
Server.get_pend_conn: number of pending connections to the server
Server.get_cur_sess: number of current sessions handled by the server

Lua documentation was updated accordingly.

doc/lua-api/index.rst
src/hlua_fcn.c

index fd3d47c77f8e5d4b2adb6fbcf72d601c4d39f23d..42c7fa65e96e93826dcca6591ca1f4c9994801cb 100644 (file)
@@ -1174,6 +1174,22 @@ Server class
    server.
   :returns: a boolean
 
+.. js:function:: Server.get_cur_sess(sv)
+
+  Return the number of currently active sessions on the server
+
+  :param class_server sv: A :ref:`server_class` which indicates the manipulated
+   server.
+  :returns: an integer
+
+.. js:function:: Server.get_pend_conn(sv)
+
+  Return the number of pending connections to the server
+
+  :param class_server sv: A :ref:`server_class` which indicates the manipulated
+   server.
+  :returns: an integer
+
 .. js:function:: Server.set_maxconn(sv, weight)
 
   Dynamically change the maximum connections of the server. See the management
index 7150b0ca34c113b2b065d7817d7973aecb50f436..3540cbdbb0b14a33fa4df28f925bfb6a5a5f6a11 100644 (file)
@@ -1119,6 +1119,34 @@ int hlua_server_is_dynamic(lua_State *L)
        return 1;
 }
 
+int hlua_server_get_cur_sess(lua_State *L)
+{
+       struct server *srv;
+
+       srv = hlua_check_server(L, 1);
+       if (srv == NULL) {
+               lua_pushnil(L);
+               return 1;
+       }
+
+       lua_pushinteger(L, srv->cur_sess);
+       return 1;
+}
+
+int hlua_server_get_pend_conn(lua_State *L)
+{
+       struct server *srv;
+
+       srv = hlua_check_server(L, 1);
+       if (srv == NULL) {
+               lua_pushnil(L);
+               return 1;
+       }
+
+       lua_pushinteger(L, srv->queue.length);
+       return 1;
+}
+
 int hlua_server_set_maxconn(lua_State *L)
 {
        struct server *srv;
@@ -1515,6 +1543,8 @@ int hlua_fcn_new_server(lua_State *L, struct server *srv)
        hlua_class_function(L, "is_draining", hlua_server_is_draining);
        hlua_class_function(L, "is_backup", hlua_server_is_backup);
        hlua_class_function(L, "is_dynamic", hlua_server_is_dynamic);
+       hlua_class_function(L, "get_cur_sess", hlua_server_get_cur_sess);
+       hlua_class_function(L, "get_pend_conn", hlua_server_get_pend_conn);
        hlua_class_function(L, "set_maxconn", hlua_server_set_maxconn);
        hlua_class_function(L, "get_maxconn", hlua_server_get_maxconn);
        hlua_class_function(L, "set_weight", hlua_server_set_weight);