From 108932cab926cf9743df7f9eaf383104130e9377 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 5 Jan 2025 14:34:04 +0100 Subject: fix: Ensure chunks are sent eventually and on exit --- internal/monitor/monitor.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/monitor/monitor.go') diff --git a/internal/monitor/monitor.go b/internal/monitor/monitor.go index ffe7f75..1f068b2 100644 --- a/internal/monitor/monitor.go +++ b/internal/monitor/monitor.go @@ -18,6 +18,7 @@ import ( "net/http" "os" "sync" + "time" ct "github.com/google/certificate-transparency-go" "github.com/google/certificate-transparency-go/client" @@ -68,6 +69,8 @@ type Config struct { Logger *logger.Logger // Debug prints only (no output by default) Contact string // Something that help log operators get in touch ChunkSize uint // Min number of leaves to propagate a chunk without matches + ChunkTime time.Duration // But always send chunks (if there are any) with this interval + ExitTime time.Duration // Maximum amount of time to spend on a graceful exit BatchSize uint // Max number of certificates to accept per worker NumWorkers uint // Number of parallel workers to use for each log } @@ -94,6 +97,12 @@ func New(cfg Config, evCh chan Event, cfgCh chan MonitoredLog, errCh chan error) if cfg.ChunkSize == 0 { cfg.ChunkSize = 4096 } + if cfg.ChunkTime == 0 { + cfg.ChunkTime = 10 * time.Minute + } + if cfg.ExitTime == 0 { + cfg.ExitTime = 10 * time.Second + } if cfg.BatchSize == 0 { cfg.BatchSize = 1024 } -- cgit v1.2.3