MINOR: lua: add get_maxconn and set_maxconn to LUA Server class.
diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst
index 9a9e7ce..ee9dab5 100644
--- a/doc/lua-api/index.rst
+++ b/doc/lua-api/index.rst
@@ -938,6 +938,23 @@
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
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index 86e5c2c..5062a19 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -592,6 +592,34 @@
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 @@
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);