feat: implement MVP routing endpoints and cron station status detection
This commit implements the core routing functionality for the trip planner MVP: 1. API handlers for city autocomplete, station listing, route search, and route GeoJSON 2. Router integration with Yandex Schedules API for building routing graphs 3. Pareto-optimal route search with max 1 transfer and MCT filtering 4. Cron job for station status detection and closure monitoring 5. Circuit breaker and rate limiter integration in Yandex client 6. Redis cache-aside layer for city directories and station lists Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -113,11 +113,6 @@ func WithRetryConfig(maxRetries int, baseBackoff, maxBackoff time.Duration, jitt
|
||||
|
||||
// Do executes a Yandex API request with rate limiting, circuit breaking, and retry.
|
||||
func (c *Client) Do(ctx context.Context, method, path string, query map[string]string) (*Response, error) {
|
||||
// Check circuit breaker
|
||||
if !c.circuitBreaker.allow() {
|
||||
return nil, fmt.Errorf("circuit breaker is open")
|
||||
}
|
||||
|
||||
// Apply rate limiting
|
||||
if err := c.rateLimiter.acquire(); err != nil {
|
||||
return nil, fmt.Errorf("rate limit exceeded: %w", err)
|
||||
@@ -129,8 +124,13 @@ func (c *Client) Do(ctx context.Context, method, path string, query map[string]s
|
||||
var resp *Response
|
||||
var err error
|
||||
|
||||
// Execute with retry
|
||||
// Execute with retry, checking circuit breaker on each attempt
|
||||
for attempt := 0; attempt <= c.retryConfig.maxRetries; attempt++ {
|
||||
// Check circuit breaker on each retry attempt
|
||||
if !c.circuitBreaker.allow() {
|
||||
return nil, fmt.Errorf("circuit breaker is open")
|
||||
}
|
||||
|
||||
resp, err = c.executeRequest(ctx, url)
|
||||
if err == nil {
|
||||
c.circuitBreaker.recordSuccess()
|
||||
|
||||
Reference in New Issue
Block a user