]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua_fcn: add Server.is_dynamic()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 29 Mar 2023 08:49:30 +0000 (10:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 14:28:32 +0000 (16:28 +0200)
This function returns true if the current server is dynamic,
meaning that it was instantiated at runtime (ie: from the cli)

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

index deef2618d1aacb5b099266dabd52432719046830..5c05871aa1077dc327b36a2b518b8c2db80bd7e9 100644 (file)
@@ -1166,6 +1166,14 @@ Server class
    server.
   :returns: a boolean
 
+.. js:function:: Server.is_dynamic(sv)
+
+  Return true if the server was instantiated at runtime (e.g.: from the cli)
+
+  :param class_server sv: A :ref:`server_class` which indicates the manipulated
+   server.
+  :returns: a boolean
+
 .. js:function:: Server.set_maxconn(sv, weight)
 
   Dynamically change the maximum connections of the server. See the management
index dc9ded4aa0b9bace1b0c12f8db924dbd20b379ca..61eb580f35402b43738a6976cdfe77702d3ddbfd 100644 (file)
@@ -1086,6 +1086,20 @@ int hlua_server_is_backup(lua_State *L)
        return 1;
 }
 
+int hlua_server_is_dynamic(lua_State *L)
+{
+       struct server *srv;
+
+       srv = hlua_check_server(L, 1);
+       if (srv == NULL) {
+               lua_pushnil(L);
+               return 1;
+       }
+
+       lua_pushboolean(L, (srv->flags & SRV_F_DYNAMIC));
+       return 1;
+}
+
 int hlua_server_set_maxconn(lua_State *L)
 {
        struct server *srv;
@@ -1437,6 +1451,7 @@ int hlua_fcn_new_server(lua_State *L, struct server *srv)
        hlua_class_function(L, "get_rid", hlua_server_get_rid);
        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, "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);