Parcourir la source

[2225_statistics] add step as kwarg into inc() and use it in dec() with step=-1

Due to the review comment.
Naoki Kambe il y a 12 ans
Parent
commit
48974a8f83
1 fichiers modifiés avec 3 ajouts et 10 suppressions
  1. 3 10
      src/lib/python/isc/statistics/counter.py

+ 3 - 10
src/lib/python/isc/statistics/counter.py

@@ -290,33 +290,26 @@ class Counters():
         with self._rlock:
         with self._rlock:
             self._disabled = False
             self._disabled = False
 
 
-    def inc(self, *args):
+    def inc(self, *args, step=1):
         """A incrementer for per-zone counter. Locks the thread
         """A incrementer for per-zone counter. Locks the thread
         because it is considered to be invoked by a multi-threading
         because it is considered to be invoked by a multi-threading
         caller. isc.cc.data.DataNotFoundError is raised when
         caller. isc.cc.data.DataNotFoundError is raised when
         incrementing the counter of the item undefined in the spec
         incrementing the counter of the item undefined in the spec
         file."""
         file."""
         identifier = _concat(*args)
         identifier = _concat(*args)
-        step = 1
         with self._rlock:
         with self._rlock:
             if self._disabled: return
             if self._disabled: return
             _inc_counter(self._statistics._data,
             _inc_counter(self._statistics._data,
                          self._statistics._spec,
                          self._statistics._spec,
                          identifier, step)
                          identifier, step)
 
 
-    def dec(self, *args):
+    def dec(self, *args, step=-1):
         """A decrementer for axfr or ixfr running. Locks the thread
         """A decrementer for axfr or ixfr running. Locks the thread
         because it is considered to be invoked by a multi-threading
         because it is considered to be invoked by a multi-threading
         caller. isc.cc.data.DataNotFoundError is raised when
         caller. isc.cc.data.DataNotFoundError is raised when
         decrementing the counter of the item undefined in the spec
         decrementing the counter of the item undefined in the spec
         file."""
         file."""
-        identifier = _concat(*args)
-        step = -1
-        with self._rlock:
-            if self._disabled: return
-            _inc_counter(self._statistics._data,
-                         self._statistics._spec,
-                         identifier, step)
+        self.inc(*args, step=step)
 
 
     def get(self, *args):
     def get(self, *args):
         """A getter method for counters. It returns the current number
         """A getter method for counters. It returns the current number