add string type enums and retry config
Publish / release (push) Successful in 1m23s

This commit is contained in:
2026-06-23 22:35:26 -04:00
parent 9b0e05d477
commit 9e94696363
6 changed files with 266 additions and 23 deletions
+18 -2
View File
@@ -25,8 +25,18 @@ import (
"time"
)
// TODO: Implement client retry configuration
// Also support exponential backoff
// RetryConfig controls how transient request failures (transport errors and 5xx
// responses) are retried. The zero value disables retries.
type RetryConfig struct {
// MaxRetries is the number of additional attempts made after the initial
// request. Zero means no retries.
MaxRetries int
// BaseDelay is the wait before the first retry. It doubles on each
// subsequent retry (exponential backoff). Zero means retry immediately.
BaseDelay time.Duration
// MaxDelay caps the per-retry backoff delay. Zero means no cap.
MaxDelay time.Duration
}
// Default ports exposed by an MGW310 station.
const (
@@ -92,6 +102,7 @@ type Client struct {
tar1090 *Endpoint
http *http.Client
userAgent string
retry RetryConfig
}
// Option customizes a Client.
@@ -125,6 +136,11 @@ func WithUserAgent(ua string) Option {
return func(c *Client) { c.userAgent = ua }
}
// WithRetry enables retries with exponential backoff for transient failures.
func WithRetry(cfg RetryConfig) Option {
return func(c *Client) { c.retry = cfg }
}
// New constructs a Client from options. A Wingbits endpoint with a non-empty
// Host must be supplied via WithWingbitsEndpoint.
func New(opts ...Option) (*Client, error) {