1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-06-10 18:08:44 -04:00

feat: Add configurable stats_store_interval for stats file saves

Add stats_store_interval config option to control how frequently
the statsstore.json file is written to disk. Default remains 10
seconds for backward compatibility.

This allows reducing disk I/O in production deployments and
can help avoid potential file corruption issues when external
processes read the stats file.
This commit is contained in:
2026-03-27 17:37:16 -04:00
parent 27413ab8cf
commit 490ff41cdc
3 changed files with 22 additions and 6 deletions
+14 -5
View File
@@ -72,11 +72,20 @@ class TestAPRSDStatsStoreThread(unittest.TestCase):
def test_init(self):
"""Test APRSDStatsStoreThread initialization."""
thread = APRSDStatsStoreThread()
self.assertEqual(thread.name, 'StatsStore')
self.assertEqual(thread.period, 10)
self.assertFalse(thread.daemon)
self.assertTrue(hasattr(thread, 'loop_count'))
with mock.patch('aprsd.threads.stats.CONF') as mock_conf:
mock_conf.stats_store_interval = 10
thread = APRSDStatsStoreThread()
self.assertEqual(thread.name, 'StatsStore')
self.assertEqual(thread.period, 10)
self.assertFalse(thread.daemon)
self.assertTrue(hasattr(thread, 'loop_count'))
def test_init_with_custom_interval(self):
"""Test APRSDStatsStoreThread uses stats_store_interval from config."""
with mock.patch('aprsd.threads.stats.CONF') as mock_conf:
mock_conf.stats_store_interval = 60
thread = APRSDStatsStoreThread()
self.assertEqual(thread.period, 60)
def test_loop_with_save(self):
"""Test loop method saves stats every call."""