Skip to content

Commit e6e3db5

Browse files
committed
remove unused return error
1 parent 2be8598 commit e6e3db5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

example.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ func main() {
2626

2727
// create a queue
2828

29-
q, err := NewSchedule(cli)
30-
if err != nil {
31-
panic(err)
32-
}
29+
sch := NewSchedule(cli)
3330

3431
// add a task
3532

@@ -43,12 +40,12 @@ func main() {
4340
},
4441
)
4542

46-
if err := q.Add(ctx, task); err != nil {
43+
if err := sch.Add(ctx, task); err != nil {
4744
panic(err)
4845
}
4946
}
5047

51-
if err := q.On(ctx, "test", func(ctx context.Context, task *Task) {
48+
if err := sch.On(ctx, "test", func(ctx context.Context, task *Task) {
5249
fmt.Printf("Executing: %v %v %v\n", task.Kind, task.ID, task.Interval)
5350
}); err != nil {
5451
panic(err)

schedule.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ type ScheduleImpl struct {
2626
redisClient *redis.Client
2727
}
2828

29-
func NewSchedule(redisClient *redis.Client) (Schedule, error) {
29+
func NewSchedule(redisClient *redis.Client) Schedule {
3030
return &ScheduleImpl{
3131
redisClient: redisClient,
32-
}, nil
32+
}
3333
}
3434

3535
func (s *ScheduleImpl) Add(ctx context.Context, task *Task) error {
@@ -45,8 +45,7 @@ func (s *ScheduleImpl) Add(ctx context.Context, task *Task) error {
4545

4646
// Find the next execution time
4747

48-
now := time.Now()
49-
nextTick := now.Add(task.Interval).UnixMilli()
48+
nextTick := time.Now().Add(task.Interval).UnixMilli()
5049

5150
// Execute redis script to
5251
// add the task to the sorted set

0 commit comments

Comments
 (0)