Repository navigation
v2.0.0 - Context Support for Cancellation and Timeouts
Breaking Changes
- All public API methods now require
context.Contextas the first parameter- This enables proper cancellation, timeouts, and graceful shutdown
- Affected methods:
GetPurchaseHistory(ctx context.Context, req PurchaseHistoryRequest)GetRecentOrders(ctx context.Context, limit int)GetAllOrders(ctx context.Context, maxPages int)SearchOrders(ctx context.Context, searchTerm string, limit int)GetOrdersByType(ctx context.Context, orderType string, limit int)GetOrder(ctx context.Context, orderID string, isInStore bool)GetOrderAutoDetect(ctx context.Context, orderID string)GetDeliveryOrderWithTip(ctx context.Context, orderID string)GetOrdersAsJSON(ctx context.Context, limit int)GetOrderAsJSON(ctx context.Context, orderID string, isInStore bool)GetOrderLedger(ctx context.Context, orderID string)
Added
- Context support for cancellation and timeouts across all API methods
- Rate limiter waits are now cancellable via context
- HTTP requests use
http.NewRequestWithContext()for proper cancellation - Exponential backoff in
GetOrderLedgerretries is now cancellable
- Context cancellation test (
TestGetOrderLedgerContextCancellation) - Improved daemon mode with graceful shutdown via SIGINT/SIGTERM
Changed
- Rate limiting now uses
selectwith context for interruptible waits GetAllOrderschecks for context cancellation between page fetchesGetOrderAutoDetectchecks for cancellation before retry attempt- Replaced
fmt.Printfpagination logging inGetAllOrderswith structuredlogger.Debug - CLI commands now use timeouts (2-10 minutes depending on operation)
Migration Guide
To migrate from v1.x to v2.0.0, add context.Context as the first parameter to all API calls:
// Before (v1.x)
orders, err := client.GetRecentOrders(10)
order, err := client.GetOrder(orderID, isInStore)
ledger, err := client.GetOrderLedger(orderID)
// After (v2.0.0)
ctx := context.Background()
orders, err := client.GetRecentOrders(ctx, 10)
order, err := client.GetOrder(ctx, orderID, isInStore)
ledger, err := client.GetOrderLedger(ctx, orderID)
// With timeout
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
orders, err := client.GetRecentOrders(ctx, 10)