]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: add get_maxconn and set_maxconn to LUA Server class.
authorPatrick Hemmer <haproxy@stormcloud9.net>
Sun, 29 Apr 2018 18:25:46 +0000 (14:25 -0400)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 May 2018 16:53:42 +0000 (18:53 +0200)
doc/lua-api/index.rst
src/hlua_fcn.c

index 9a9e7ceef86e97713a608b89df29cb6f19e65d31..ee9dab55cfb7aa03495ac8bb203378a50ee77cf2 100644 (file)
@@ -938,6 +938,23 @@ Server class
     server.
   :returns: a boolean
 
+.. js:function:: Server.set_maxconn(sv, weight)
+
+  Dynamically change the maximum connections of the server. See the management
+  socket documentation for more information about the format of the string.
+
+  :param class_server sv: A :ref:`server_class` which indicates the manipulated
+    server.
+  :param string maxconn: A string describing the server maximum connections.
+
+.. js:function:: Server.get_maxconn(sv, weight)
+
+  This function returns an integer representing the server maximum connections.
+
+  :param class_server sv: A :ref:`server_class` which indicates the manipulated
+    server.
+  :returns: an integer.
+
 .. js:function:: Server.set_weight(sv, weight)
 
   Dynamically change the weight of the server. See the management socket
index 86e5c2c749ce75c54bebc0ef01f29373dcfc8e3f..5062a196f3d1e79a960aa10a10a287ff22126193 100644 (file)
@@ -592,6 +592,34 @@ int hlua_server_is_draining(lua_State *L)
        return 1;
 }
 
+int hlua_server_set_maxconn(lua_State *L)
+{
+       struct server *srv;
+       const char *maxconn;
+       const char *err;
+
+       srv = hlua_check_server(L, 1);
+       maxconn = luaL_checkstring(L, 2);
+
+       HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
+       err = server_parse_maxconn_change_request(srv, maxconn);
+       HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
+       if (!err)
+               lua_pushnil(L);
+       else
+               hlua_pushstrippedstring(L, err);
+       return 1;
+}
+
+int hlua_server_get_maxconn(lua_State *L)
+{
+       struct server *srv;
+
+       srv = hlua_check_server(L, 1);
+       lua_pushinteger(L, srv->maxconn);
+       return 1;
+}
+
 int hlua_server_set_weight(lua_State *L)
 {
        struct server *srv;
@@ -1274,6 +1302,8 @@ int hlua_fcn_reg_core_fcn(lua_State *L)
        lua_pushstring(L, "__index");
        lua_newtable(L);
        hlua_class_function(L, "is_draining", hlua_server_is_draining);
+       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);
        hlua_class_function(L, "get_weight", hlua_server_get_weight);
        hlua_class_function(L, "set_addr", hlua_server_set_addr);