From c019e4cd0e4857f2594dedc9746eb8fffb436adb Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 2 Dec 2025 15:58:59 +0000 Subject: [PATCH] docs: Add godoc comments to exported functions Add missing godoc comments to: - NewRateLimiter and Allow in ratelimit.go - SnapshotSyncStatus in temperature_proxy.go - NewClient and GetVersion in pkg/pmg/client.go --- internal/api/ratelimit.go | 4 ++++ internal/api/temperature_proxy.go | 1 + pkg/pmg/client.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/internal/api/ratelimit.go b/internal/api/ratelimit.go index 8791897..4f49bfe 100644 --- a/internal/api/ratelimit.go +++ b/internal/api/ratelimit.go @@ -14,6 +14,8 @@ type RateLimiter struct { stopCleanup chan struct{} } +// NewRateLimiter creates a rate limiter that allows limit requests per window duration. +// It starts a background goroutine to periodically clean up old entries. func NewRateLimiter(limit int, window time.Duration) *RateLimiter { rl := &RateLimiter{ attempts: make(map[string][]time.Time), @@ -45,6 +47,8 @@ func (rl *RateLimiter) Stop() { close(rl.stopCleanup) } +// Allow checks if a request from the given IP address is within the rate limit. +// Returns true if the request is allowed, false if the rate limit is exceeded. func (rl *RateLimiter) Allow(ip string) bool { rl.mu.Lock() defer rl.mu.Unlock() diff --git a/internal/api/temperature_proxy.go b/internal/api/temperature_proxy.go index 7b1f02f..c5021ba 100644 --- a/internal/api/temperature_proxy.go +++ b/internal/api/temperature_proxy.go @@ -84,6 +84,7 @@ func (h *TemperatureProxyHandlers) recordSync(instance string, refreshSeconds in } } +// SnapshotSyncStatus returns a copy of the current sync status for all temperature proxies. func (h *TemperatureProxyHandlers) SnapshotSyncStatus() map[string]proxySyncState { if h == nil { return nil diff --git a/pkg/pmg/client.go b/pkg/pmg/client.go index 0e88d7c..e7dd00f 100644 --- a/pkg/pmg/client.go +++ b/pkg/pmg/client.go @@ -126,6 +126,7 @@ type BackupEntry struct { Timestamp flexibleInt `json:"timestamp"` } +// NewClient creates a new PMG (Proxmox Mail Gateway) API client. func NewClient(cfg ClientConfig) (*Client, error) { if cfg.Timeout <= 0 { cfg.Timeout = 60 * time.Second @@ -395,6 +396,7 @@ func (c *Client) getJSON(ctx context.Context, path string, params url.Values, ou return nil } +// GetVersion returns version information for the PMG instance. func (c *Client) GetVersion(ctx context.Context) (*VersionInfo, error) { var resp apiResponse[VersionInfo] if err := c.getJSON(ctx, "/version", nil, &resp); err != nil {