package meteo import ( "context" "fmt" "log/slog" "net/http" "sync" "time" ) type inMemory struct { data any mu *sync.RWMutex expiry time.Time } type Service struct { inMemory } func NewService() *Service { return &Service{} } func (s *Service) GetWeatherByCity(ctx context.Context, params GetMeteoData) ([]MeteoData, error) { fromDate, err := time.Parse("2006-01-02", params.Date) if err != nil { return nil, err } toDate := fromDate.AddDate(0, 0, params.Days-1) url := fmt.Sprintf("http://localhost:8080/data?city=%s&from=%s&to=%s", params.Location, params.Date, toDate.Format("2006-01-02")) resp, err := http.Get(url) if err != nil { return nil, err } defer resp.Body.Close() // TODO add backoff // TODO add ristretto slog.Info("fetched data", "data", resp) return []MeteoData{}, nil }