refactor(scheduler): replace uuid with id.NewRandom for schedule ID generation

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-12-24 10:48:25 -05:00
parent 1a7ba7f293
commit b2e1c216a0
2 changed files with 4 additions and 4 deletions

View File

@ -6,8 +6,8 @@ import (
"sync"
"time"
"github.com/google/uuid"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model/id"
"github.com/navidrome/navidrome/plugins/host"
"github.com/navidrome/navidrome/scheduler"
)
@ -49,7 +49,7 @@ func newSchedulerService(pluginName string, manager *Manager, sched scheduler.Sc
func (s *schedulerServiceImpl) ScheduleOneTime(ctx context.Context, delaySeconds int32, payload string, scheduleID string) (string, error) {
if scheduleID == "" {
scheduleID = uuid.New().String()
scheduleID = id.NewRandom()
}
s.mu.Lock()
@ -81,7 +81,7 @@ func (s *schedulerServiceImpl) ScheduleOneTime(ctx context.Context, delaySeconds
func (s *schedulerServiceImpl) ScheduleRecurring(ctx context.Context, cronExpression string, payload string, scheduleID string) (string, error) {
if scheduleID == "" {
scheduleID = uuid.New().String()
scheduleID = id.NewRandom()
}
capturedID := scheduleID

View File

@ -128,7 +128,7 @@ var _ = Describe("SchedulerService", Ordered, func() {
It("should auto-generate schedule ID when empty", func() {
scheduleID, err := testService.ScheduleOneTime(GinkgoT().Context(), 1, "data", "")
Expect(err).ToNot(HaveOccurred())
Expect(scheduleID).To(HaveLen(36)) // UUID format
Expect(scheduleID).ToNot(BeEmpty())
})
})