代码拉取完成,页面将自动刷新
/*
Copyright 2022 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"time"
"github.com/sirupsen/logrus"
"gitee.com/kubeship/kube-trigger/pkg/executor"
)
type option struct {
LogLevel string
Config string
QueueSize int
Workers int
PerWorkerQPS int
MaxRetry int
RetryDelay int
ActionRetry bool
Timeout int
RegistrySize int
}
const (
defaultLogLevel = "info"
defaultConfig = "config.cue"
defaultQueueSize = 50
defaultWorkers = 4
defaultPerWorkerQPS = 2
defaultMaxRetry = 5
defaultRetryDelay = 2
defaultActionRetry = false
defaultTimeout = 10
defaultRegistrySize = 100
// Values taken from: https://github.com/kubernetes/component-base/blob/master/config/v1alpha1/defaults.go
defaultLeaseDuration = 15 * time.Second
defaultRenewDeadline = 10 * time.Second
defaultRetryPeriod = 2 * time.Second
)
func newOption() *option {
return &option{}
}
func (o *option) validate() error {
_, err := logrus.ParseLevel(o.LogLevel)
if err != nil {
return err
}
if o.Config == "" {
return fmt.Errorf("%s not specified", FlagConfig)
}
if o.QueueSize <= 0 {
return fmt.Errorf("%s must be greater than 0", FlagQueueSize)
}
if o.Workers <= 0 {
return fmt.Errorf("%s must be greater than 0", FlagWorkers)
}
if o.PerWorkerQPS <= 0 {
return fmt.Errorf("%s must be greater than 0", FlagPerWorkerQPS)
}
if o.MaxRetry < 0 {
return fmt.Errorf("%s must be greater or equal to 0", FlagMaxRetry)
}
if o.RetryDelay < 0 {
return fmt.Errorf("%s must be greater or equal to 0", FlagRetryDelay)
}
if o.Timeout <= 0 {
return fmt.Errorf("%s must be greater than 0", FlagTimeout)
}
if o.RegistrySize <= 0 {
return fmt.Errorf("%s must be greater than 0", FlagRegistrySize)
}
return nil
}
func (o *option) getExecutorConfig() executor.Config {
return executor.Config{
QueueSize: o.QueueSize,
Workers: o.Workers,
MaxJobRetries: o.MaxRetry,
BaseRetryDelay: time.Second * time.Duration(o.RetryDelay),
RetryJobAfterFailure: o.ActionRetry,
PerWorkerQPS: o.PerWorkerQPS,
Timeout: time.Second * time.Duration(o.Timeout),
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。