Skip to content
Snippets Groups Projects
Commit 3c29efde authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček
Browse files

predict: don't auto-load stats if not needed

and make docs conform to the reality.
parent 7ac98a29
Branches
Tags
1 merge request!537Nitpicks
......@@ -15,8 +15,6 @@ ahead of time. This is helpful to minimize the perceived latency and keeps the c
Example configuration
^^^^^^^^^^^^^^^^^^^^^
.. warning:: This module requires 'stats' module to be present and loaded.
.. code-block:: lua
modules = {
......@@ -29,7 +27,9 @@ Example configuration
Defaults are 15 minutes window, 6 hours period.
.. tip:: Use period 0 to turn off prediction and just do prefetching of expiring records.
That works even without the 'stats' module.
That works even without the :ref:`stats <mod-stats>` module.
.. note:: Otherwise this module requires :ref:`stats <mod-stats>` module and loads it if not present.
Exported metrics
^^^^^^^^^^^^^^^^
......@@ -45,7 +45,7 @@ Properties
^^^^^^^^^^
.. function:: predict.config({ window = 15, period = 24})
Reconfigure the predictor to given tracking window and period length. Both parameters are optional.
Window length is in minutes, period is a number of windows that can be kept in memory.
e.g. if a ``window`` is 15 minutes, a ``period`` of "24" means 6 hours.
......@@ -13,8 +13,6 @@ local predict = {
log = {},
}
-- Load dependent modules
if not stats then modules.load('stats') end
-- Calculate next sample with jitter [1-2/5 of window]
local function next_event()
......@@ -163,6 +161,8 @@ function predict.config(config)
if type(config) ~= 'table' then return end
if config.window then predict.window = config.window end
if config.period then predict.period = config.period end
-- Load dependent modules
if (predict.period or 0) ~= 0 and not stats then modules.load('stats') end
-- Reinitialize to reset timers
predict.deinit()
predict.init()
......
-- setup resolver
modules = { 'predict' }
modules = { 'predict', 'stats' }
-- mock global functions
local resolve_count = 0
......@@ -57,4 +57,4 @@ end
return {
test_predict_drain,
test_predict_process
}
\ No newline at end of file
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment