feat(macros): add IndexerName (#1511)

* feat(macros): add IndexerName

* fix: tests

* fix: tests
This commit is contained in:
ze0s 2024-04-16 17:35:17 +02:00 committed by GitHub
parent c43e2c76d6
commit 3c3b47fa10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 310 additions and 235 deletions

View file

@ -42,14 +42,14 @@ type Service interface {
}
type feedInstance struct {
Feed *domain.Feed
Name string
IndexerIdentifier string
URL string
ApiKey string
Implementation string
CronSchedule time.Duration
Timeout time.Duration
Feed *domain.Feed
Name string
Indexer domain.IndexerMinimal
URL string
ApiKey string
Implementation string
CronSchedule time.Duration
Timeout time.Duration
}
// feedKey creates a unique identifier to be used for controlling jobs in the scheduler
@ -349,14 +349,14 @@ func (s *service) restartJob(f *domain.Feed) error {
func newFeedInstance(f *domain.Feed) feedInstance {
// cron schedule to run every X minutes
fi := feedInstance{
Feed: f,
Name: f.Name,
IndexerIdentifier: f.Indexer,
Implementation: f.Type,
URL: f.URL,
ApiKey: f.ApiKey,
CronSchedule: time.Duration(f.Interval) * time.Minute,
Timeout: time.Duration(f.Timeout) * time.Second,
Feed: f,
Name: f.Name,
Indexer: f.Indexer,
Implementation: f.Type,
URL: f.URL,
ApiKey: f.ApiKey,
CronSchedule: time.Duration(f.Interval) * time.Minute,
Timeout: time.Duration(f.Timeout) * time.Second,
}
return fi
@ -403,11 +403,11 @@ func (s *service) startJob(f *domain.Feed) error {
job, err := s.initializeFeedJob(fi)
if err != nil {
return errors.Wrap(err, "initialize job %s failed", f.Indexer)
return errors.Wrap(err, "initialize job %s failed", f.Name)
}
if err := s.scheduleJob(fi, job); err != nil {
return errors.Wrap(err, "schedule job %s failed", f.Indexer)
return errors.Wrap(err, "schedule job %s failed", f.Name)
}
s.log.Debug().Msgf("successfully started feed: %s", f.Name)
@ -448,7 +448,7 @@ func (s *service) createTorznabJob(f feedInstance) (FeedJob, error) {
client := torznab.NewClient(torznab.Config{Host: f.URL, ApiKey: f.ApiKey, Timeout: f.Timeout})
// create job
job := NewTorznabJob(f.Feed, f.Name, f.IndexerIdentifier, l, f.URL, client, s.repo, s.cacheRepo, s.releaseSvc)
job := NewTorznabJob(f.Feed, f.Name, l, f.URL, client, s.repo, s.cacheRepo, s.releaseSvc)
return job, nil
}
@ -467,7 +467,7 @@ func (s *service) createNewznabJob(f feedInstance) (FeedJob, error) {
client := newznab.NewClient(newznab.Config{Host: f.URL, ApiKey: f.ApiKey, Timeout: f.Timeout})
// create job
job := NewNewznabJob(f.Feed, f.Name, f.IndexerIdentifier, l, f.URL, client, s.repo, s.cacheRepo, s.releaseSvc)
job := NewNewznabJob(f.Feed, f.Name, l, f.URL, client, s.repo, s.cacheRepo, s.releaseSvc)
return job, nil
}
@ -487,7 +487,7 @@ func (s *service) createRSSJob(f feedInstance) (FeedJob, error) {
l := s.log.With().Str("feed", f.Name).Logger()
// create job
job := NewRSSJob(f.Feed, f.Name, f.IndexerIdentifier, l, f.URL, s.repo, s.cacheRepo, s.releaseSvc, f.Timeout)
job := NewRSSJob(f.Feed, f.Name, l, f.URL, s.repo, s.cacheRepo, s.releaseSvc, f.Timeout)
return job, nil
}