mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
Make cache ttl for bird responses a config option
For bird and bird6 you may add ttl to the respective config file sections. See example config in this commit. This allows to have individual ttls for the cache of bird cli output per daemon.
This commit is contained in:
parent
e4ec6591b9
commit
46356aa9eb
4 changed files with 9 additions and 3 deletions
|
@ -49,7 +49,11 @@ func fromCache(key string) (Parsed, bool) {
|
|||
}
|
||||
|
||||
func toCache(key string, val Parsed) {
|
||||
val["ttl"] = time.Now().Add(10 * time.Minute)
|
||||
var ttl int = 5
|
||||
if ClientConf.CacheTtl > 0 {
|
||||
ttl = ClientConf.CacheTtl
|
||||
}
|
||||
val["ttl"] = time.Now().Add(time.Duration(ttl) * time.Minute)
|
||||
Cache.Lock()
|
||||
Cache.m[key] = val
|
||||
Cache.Unlock()
|
||||
|
|
|
@ -13,6 +13,7 @@ type BirdConfig struct {
|
|||
Listen string
|
||||
ConfigFilename string `toml:"config"`
|
||||
BirdCmd string `toml:"birdc"`
|
||||
CacheTtl int `toml:"ttl"`
|
||||
}
|
||||
|
||||
type ParserConfig struct {
|
||||
|
|
|
@ -89,6 +89,7 @@ func PrintServiceInfo(conf *Config, birdConf bird.BirdConfig) {
|
|||
log.Println("Starting Birdwatcher")
|
||||
log.Println(" Using:", birdConf.BirdCmd)
|
||||
log.Println(" Listen:", birdConf.Listen)
|
||||
log.Println(" Cache TTL:", birdConf.CacheTtl)
|
||||
|
||||
// Endpoint Info
|
||||
if len(conf.Server.AllowFrom) == 0 {
|
||||
|
|
|
@ -45,12 +45,13 @@ requests_per_minute = 10
|
|||
listen = "0.0.0.0:29188"
|
||||
config = "/etc/bird.conf"
|
||||
birdc = "/sbin/birdc"
|
||||
|
||||
ttl = 5 # time to live (in minutes) for caching of cli output
|
||||
|
||||
[bird6]
|
||||
listen = "0.0.0.0:29189"
|
||||
config = "/etc/bird6.conf"
|
||||
birdc = "/sbin/birdc6"
|
||||
ttl = 5 # time to live (in minutes) for caching of cli output
|
||||
|
||||
[parser]
|
||||
# Remove fields e.g. interface
|
||||
|
@ -60,4 +61,3 @@ filter_fields = []
|
|||
per_peer_tables = true
|
||||
peer_protocol_prefix = 'ID'
|
||||
pipe_protocol_prefix = 'P'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue