Files
kumomta/assets/tsa_init.lua
T
Wez Furlong 1872dc71a0 shaping: calling shaper.should_enqueue_log_record is no longer required
Allow multiple should_enqueue_log_record hooks to be registered,
and take advantage of that inside the shaping helper.

`shaper.should_enqueue_log_record` no longer needs to be explicitly
plumbed from the config, but we allow calling it still for compatibility
reasons.

We will remove that compatibility after the next stable release.
2023-11-03 08:52:40 -07:00

24 lines
554 B
Lua

local tsa = require 'tsa'
local kumo = require 'kumo'
kumo.on('tsa_init', function()
tsa.start_http_listener {
listen = '0.0.0.0:8008',
trusted_hosts = { '127.0.0.1', '::1' },
}
end)
local cached_load_shaping_data = kumo.memoize(kumo.shaping.load, {
name = 'tsa_load_shaping_data',
ttl = '5 minutes',
capacity = 4,
})
kumo.on('tsa_load_shaping_data', function()
local shaping = cached_load_shaping_data {
'/opt/kumomta/share/policy-extras/shaping.toml',
-- "assets/policy-extras/shaping.toml",
}
return shaping
end)