Skip to content

Commit

Permalink
remove unused return error
Browse files Browse the repository at this point in the history
  • Loading branch information
naueramant committed Dec 20, 2022
1 parent 2be8598 commit e6e3db5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 3 additions & 6 deletions example.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ func main() {

// create a queue

q, err := NewSchedule(cli)
if err != nil {
panic(err)
}
sch := NewSchedule(cli)

// add a task

Expand All @@ -43,12 +40,12 @@ func main() {
},
)

if err := q.Add(ctx, task); err != nil {
if err := sch.Add(ctx, task); err != nil {
panic(err)
}
}

if err := q.On(ctx, "test", func(ctx context.Context, task *Task) {
if err := sch.On(ctx, "test", func(ctx context.Context, task *Task) {
fmt.Printf("Executing: %v %v %v\n", task.Kind, task.ID, task.Interval)
}); err != nil {
panic(err)
Expand Down
7 changes: 3 additions & 4 deletions schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type ScheduleImpl struct {
redisClient *redis.Client
}

func NewSchedule(redisClient *redis.Client) (Schedule, error) {
func NewSchedule(redisClient *redis.Client) Schedule {
return &ScheduleImpl{
redisClient: redisClient,
}, nil
}
}

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

// Find the next execution time

now := time.Now()
nextTick := now.Add(task.Interval).UnixMilli()
nextTick := time.Now().Add(task.Interval).UnixMilli()

// Execute redis script to
// add the task to the sorted set
Expand Down

0 comments on commit e6e3db5

Please sign in to comment.