mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
refactor(scheduler): replace uuid with id.NewRandom for schedule ID generation
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
1a7ba7f293
commit
b2e1c216a0
@ -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
|
||||
|
||||
@ -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())
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user