Validate queue name in Inspector

This commit is contained in:
Ken Hibino
2020-08-31 05:53:17 -07:00
parent 131ac823fd
commit dab8295883
2 changed files with 69 additions and 2 deletions

View File

@@ -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