forked from RichardKnop/machinery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
32 lines (26 loc) · 770 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package tasks
import (
"fmt"
"time"
)
// ErrRetryTaskLater ...
type ErrRetryTaskLater struct {
name, msg string
retryIn time.Duration
}
// RetryIn returns time.Duration from now when task should be retried
func (e ErrRetryTaskLater) RetryIn() time.Duration {
return e.retryIn
}
// Error implements the error interface
func (e ErrRetryTaskLater) Error() string {
return fmt.Sprintf("Task error: %s Will retry in: %s", e.msg, e.retryIn)
}
// NewErrRetryTaskLater returns new ErrRetryTaskLater instance
func NewErrRetryTaskLater(msg string, retryIn time.Duration) ErrRetryTaskLater {
return ErrRetryTaskLater{msg: msg, retryIn: retryIn}
}
// Retriable is interface that retriable errors should implement
type Retriable interface {
RetryIn() time.Duration
}