]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add :getQueries() method to Server class
authorLucas Rolff <lucas@lucasrolff.com>
Thu, 26 Jun 2025 20:36:03 +0000 (22:36 +0200)
committerLucas Rolff <lucas@lucasrolff.com>
Thu, 26 Jun 2025 20:36:03 +0000 (22:36 +0200)
This exposes the total number of queries a downstream server has handled
similarly to how the :getDrops() method are available within Lua

When doing custom logic within Lua it's sometimes useful to be able to
know how many queries a given server has handled, so this simply exposes
that metric within the Server class directly.

pdns/dnsdistdist/dnsdist-lua-bindings.cc
pdns/dnsdistdist/docs/reference/config.rst

index 776e776baaa758e3fa13c1d3f9b8c48f3ae72a29..a210eb10ab6b49ce64f588f4b77d8753e00c416f 100644 (file)
@@ -121,6 +121,7 @@ void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck)
   });
   luaCtx.registerFunction<uint64_t (DownstreamState::*)() const>("getOutstanding", [](const DownstreamState& state) { return state.outstanding.load(); });
   luaCtx.registerFunction<uint64_t (DownstreamState::*)() const>("getDrops", [](const DownstreamState& state) { return state.reuseds.load(); });
+  luaCtx.registerFunction<uint64_t (DownstreamState::*)() const>("getQueries", [](const DownstreamState& state) { return state.queries.load(); });
   luaCtx.registerFunction<double (DownstreamState::*)() const>("getLatency", [](const DownstreamState& state) { return state.getRelevantLatencyUsec(); });
   luaCtx.registerFunction("isUp", &DownstreamState::isUp);
   luaCtx.registerFunction("setDown", &DownstreamState::setDown);
index e9b8d4bda52c575d94a60e453c881943e58aa55c..4dba6116aef658a78a70201f011e3c9a463ab675 100644 (file)
@@ -829,6 +829,14 @@ A server object returned by :func:`getServer` can be manipulated with these func
 
     :returns: The number of dropped queries
 
+  .. method:: Server:getQueries() -> int
+
+    .. versionadded:: 2.0.x
+
+    Get the number of total queries for this server.
+
+    :returns: The number of dropped queries
+
   .. method:: Server:getHealthCheckMode() -> str
 
     .. versionadded:: 2.0.0