28 lines
592 B
Go
28 lines
592 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"watch-party-backend/internal/repo"
|
|
)
|
|
|
|
type EpisodeService interface {
|
|
GetCurrent(ctx context.Context) (repo.Episode, error)
|
|
}
|
|
|
|
type episodeService struct {
|
|
repo repo.EpisodeRepository
|
|
}
|
|
|
|
func NewEpisodeService(r repo.EpisodeRepository) EpisodeService {
|
|
return &episodeService{repo: r}
|
|
}
|
|
|
|
func (s *episodeService) GetCurrent(ctx context.Context) (repo.Episode, error) {
|
|
// Add cross-cutting concerns here (timeouts, metrics, caching, etc.)
|
|
c, cancel := context.WithTimeout(ctx, 3*time.Second)
|
|
defer cancel()
|
|
return s.repo.GetCurrent(c)
|
|
}
|