diff options
| author | Fuwn <[email protected]> | 2026-01-19 16:53:39 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-19 16:53:39 -0800 |
| commit | b83baaae6735eccca31a94e630fdeb67919733a0 (patch) | |
| tree | 625deb2572ed2e8cefa607e88c764c7c21344802 /internal/monitor/monitor.go | |
| parent | feat: Add reset_on_next_check flag to wipe monitor history (diff) | |
| download | kaze-b83baaae6735eccca31a94e630fdeb67919733a0.tar.xz kaze-b83baaae6735eccca31a94e630fdeb67919733a0.zip | |
feat: Add group defaults, content checking, SSL tracking for Gemini, hide/round options
Diffstat (limited to 'internal/monitor/monitor.go')
| -rw-r--r-- | internal/monitor/monitor.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/internal/monitor/monitor.go b/internal/monitor/monitor.go index b0c2f4f..cbf01b3 100644 --- a/internal/monitor/monitor.go +++ b/internal/monitor/monitor.go @@ -34,7 +34,7 @@ type Monitor interface { // Name returns the monitor's name Name() string - // Type returns the monitor type (http, https, tcp) + // Type returns the monitor type (http, https, tcp, gemini) Type() string // Target returns the monitor target (URL or host:port) @@ -46,6 +46,12 @@ type Monitor interface { // Retries returns the number of retry attempts Retries() int + // HideSSLDays returns whether to hide SSL days from display + HideSSLDays() bool + + // RoundResponseTime returns whether to round response time + RoundResponseTime() bool + // Check performs the monitoring check and returns the result Check(ctx context.Context) *Result } @@ -89,3 +95,22 @@ func (r *Result) ToCheckResult() *storage.CheckResult { } return cr } + +// ToCheckResultWithOptions converts a monitor Result to a storage CheckResult with display options applied +func (r *Result) ToCheckResultWithOptions(mon Monitor) *storage.CheckResult { + cr := r.ToCheckResult() + + // Apply rounding if enabled + if mon.RoundResponseTime() { + // Round to nearest second (1000ms) + cr.ResponseTime = ((cr.ResponseTime + 500) / 1000) * 1000 + } + + // Hide SSL days if enabled + if mon.HideSSLDays() { + cr.SSLDaysLeft = 0 + cr.SSLExpiry = nil + } + + return cr +} |