Fixed parsing of timeout in metadata
@@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"net/url"
+ "strconv"
"strings"
"time"
@@ -40,8 +41,9 @@ type BaseMetadata struct {
CfAccountID string `mapstructure:"cfAccountID"`
Key string `mapstructure:"key"`
WorkerName string `mapstructure:"workerName"`
- Timeout time.Duration `mapstructure:"timeout"`
+ TimeoutInSeconds string `mapstructure:"timeoutInSeconds"`
+ Timeout time.Duration `mapstructure:"-"`
privKey ed25519.PrivateKey
}
@@ -67,8 +69,15 @@ func (m *BaseMetadata) Validate() error {
}
// Timeout
- if m.Timeout < time.Second {
m.Timeout = defaultTimeout
+ if m.TimeoutInSeconds != "" {
+ timeout, err := strconv.Atoi(m.TimeoutInSeconds)
+ if err != nil {
+ return fmt.Errorf("failed to parse value for 'timeoutInSeconds': %w", err)
+ }
+ if timeout > 0 {
+ m.Timeout = time.Duration(timeout) * time.Second
+ }
}
// WorkerName
