Contain an array with the attached servers. Each server entry is an object of
type :ref:`server_class`.
+.. js:attribute:: Proxy.listeners
+
+ Contain an array with the attached listeners. Each listeners entry is an
+ object of type :ref:`listener_class`.
+
.. js:function:: Proxy.pause(px)
Pause the proxy. See the management socket documentation for more information.
:param class_server sv: A :ref:`server_class` which indicates the manipulated
server.
+.. _listener_class:
+
+Listener class
+==============
+
+.. js:function:: Listener.get_stats(ls)
+
+ Returns server statistics.
+
+ :param class_listener ls: A :ref:`listener_class` which indicates the
+ manipulated listener.
+ :returns: a key/value array containing stats
+
.. _concat_class:
Concat class
static int class_concat_ref;
static int class_proxy_ref;
static int class_server_ref;
+static int class_listener_ref;
#define STATS_LEN (MAX((int)ST_F_TOTAL_FIELDS, (int)INF_TOTAL_FIELDS))
return 1;
}
+int hlua_fcn_new_listener(lua_State *L, struct listener *lst)
+{
+ lua_newtable(L);
+
+ /* Pop a class sesison metatable and affect it to the userdata. */
+ lua_rawgeti(L, LUA_REGISTRYINDEX, class_listener_ref);
+ lua_setmetatable(L, -2);
+
+ lua_pushlightuserdata(L, lst);
+ lua_rawseti(L, -2, 0);
+ return 1;
+}
+
+static struct listener *hlua_check_listener(lua_State *L, int ud)
+{
+ return (struct listener *)(hlua_checkudata(L, ud, class_listener_ref));
+}
+
+int hlua_listener_get_stats(lua_State *L)
+{
+ struct listener *li;
+ int i;
+
+ li = hlua_check_listener(L, 1);
+
+ if (!li->frontend) {
+ lua_pushnil(L);
+ return 1;
+ }
+
+ stats_fill_li_stats(li->frontend, li, ST_SHLGNDS, stats, STATS_LEN);
+
+ lua_newtable(L);
+ for (i=0; i<ST_F_TOTAL_FIELDS; i++) {
+ lua_pushstring(L, stat_field_names[i]);
+ hlua_fcn_pushfield(L, &stats[i]);
+ lua_settable(L, -3);
+ }
+ return 1;
+
+}
+
int hlua_fcn_new_server(lua_State *L, struct server *srv)
{
lua_newtable(L);
int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
{
struct server *srv;
+ struct listener *lst;
+ int lid;
+ char buffer[10];
lua_newtable(L);
}
lua_settable(L, -3);
+ /* Browse and register listeners. */
+ lua_pushstring(L, "listeners");
+ lua_newtable(L);
+ lid = 1;
+ list_for_each_entry(lst, &px->conf.listeners, by_fe) {
+ if (lst->name)
+ lua_pushstring(L, lst->name);
+ else {
+ snprintf(buffer, 10, "sock-%d", lid);
+ lid++;
+ lua_pushstring(L, buffer);
+ }
+ hlua_fcn_new_listener(L, lst);
+ lua_settable(L, -3);
+ }
+ lua_settable(L, -3);
+
return 1;
}
hlua_class_function(L, "concat", hlua_concat_new);
hlua_class_function(L, "get_info", hlua_get_info);
+ /* Create listener object. */
+ lua_newtable(L);
+ lua_pushstring(L, "__index");
+ lua_newtable(L);
+ hlua_class_function(L, "get_stats", hlua_listener_get_stats);
+ lua_settable(L, -3); /* -> META["__index"] = TABLE */
+ class_listener_ref = hlua_register_metatable(L, CLASS_LISTENER);
+
/* Create server object. */
lua_newtable(L);
lua_pushstring(L, "__index");