Add configurable timeouts and cache validity to ESI and SSO components

This commit is contained in:
2025-10-10 22:38:09 +02:00
parent fe47d3f8dd
commit 0f0adac82a
5 changed files with 78 additions and 50 deletions

View File

@@ -8,6 +8,8 @@ import (
"strings"
"time"
"go-eve-pi/options"
logger "git.site.quack-lab.dev/dave/cylogger"
)
@@ -23,12 +25,19 @@ type ZulipWebhook struct {
func NewZulipWebhook(url, email, token string) *ZulipWebhook {
logger.Info("Zulip webhook client initialized with email: %s", email)
// Parse HTTP timeout ONCE at initialization
httpTimeout, err := time.ParseDuration(options.GlobalOptions.HTTPTimeout)
if err != nil {
logger.Warning("Invalid HTTP timeout duration %s, using 30s default: %v", options.GlobalOptions.HTTPTimeout, err)
httpTimeout = 30 * time.Second
}
return &ZulipWebhook{
url: url,
email: email,
token: token,
client: &http.Client{
Timeout: 30 * time.Second,
Timeout: httpTimeout,
},
}
}