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
This commit is contained in:
parent
25294da5d5
commit
c019e4cd0e
3 changed files with 7 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue