mirror of
https://github.com/hibiken/asynq.git
synced 2025-09-19 05:17:30 +08:00
Validate queue name in Inspector
This commit is contained in:
11
client.go
11
client.go
@@ -132,8 +132,8 @@ func composeOptions(opts ...Option) (option, error) {
|
||||
res.retry = int(opt)
|
||||
case queueOption:
|
||||
trimmed := strings.TrimSpace(string(opt))
|
||||
if len(trimmed) == 0 {
|
||||
return option{}, fmt.Errorf("queue name must contain one or more characters")
|
||||
if err := validateQueueName(trimmed); err != nil {
|
||||
return option{}, err
|
||||
}
|
||||
res.queue = trimmed
|
||||
case timeoutOption:
|
||||
@@ -149,6 +149,13 @@ func composeOptions(opts ...Option) (option, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func validateQueueName(qname string) error {
|
||||
if len(qname) == 0 {
|
||||
return fmt.Errorf("queue name must contain one or more characters")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
// Default max retry count used if nothing is specified.
|
||||
defaultMaxRetry = 25
|
||||
|
Reference in New Issue
Block a user