]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: Add server name & puid to LUA Server class.
authorPatrick Hemmer <phemmer@stormcloud9.net>
Sun, 29 Apr 2018 18:23:48 +0000 (14:23 -0400)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 May 2018 16:44:44 +0000 (18:44 +0200)
doc/lua-api/index.rst
src/hlua_fcn.c

index 9b6d18f46262fc5c2f31e50c85fd8d8e073d099d..9a9e7ceef86e97713a608b89df29cb6f19e65d31 100644 (file)
@@ -922,6 +922,14 @@ Server class
 
   This class provides a way for manipulating servers and retrieving information.
 
+.. js:attribute:: Server.name
+
+  Contain the name of the server.
+
+.. js:attribute:: Server.puid
+
+  Contain the proxy unique identifier of the server.
+
 .. js:function:: Server.is_draining(sv)
 
   Return true if the server is currently draining sticky connections.
index a8d53d45b7d1ede813b17d8b77e34feb3be05e33..86e5c2c749ce75c54bebc0ef01f29373dcfc8e3f 100644 (file)
@@ -490,6 +490,8 @@ int hlua_listener_get_stats(lua_State *L)
 
 int hlua_fcn_new_server(lua_State *L, struct server *srv)
 {
+       char buffer[12];
+
        lua_newtable(L);
 
        /* Pop a class sesison metatable and affect it to the userdata. */
@@ -498,6 +500,18 @@ int hlua_fcn_new_server(lua_State *L, struct server *srv)
 
        lua_pushlightuserdata(L, srv);
        lua_rawseti(L, -2, 0);
+
+       /* Add server name. */
+       lua_pushstring(L, "name");
+       lua_pushstring(L, srv->id);
+       lua_settable(L, -3);
+
+       /* Add server puid. */
+       lua_pushstring(L, "puid");
+       snprintf(buffer, sizeof(buffer), "%d", srv->puid);
+       lua_pushstring(L, buffer);
+       lua_settable(L, -3);
+
        return 1;
 }