1 Star 0 Fork 0

xingyp / cn-infra

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
Lukas Macko 提交于 2018-11-26 12:39 . Support non-fatal errors
// Copyright (c) 2018 Cisco and/or its affiliates.
//
// 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 probe
import (
"github.com/ligato/cn-infra/health/statuscheck"
"github.com/ligato/cn-infra/logging"
"github.com/ligato/cn-infra/rpc/rest"
"github.com/ligato/cn-infra/servicelabel"
)
// DefaultPlugin is a default instance of Plugin.
var DefaultPlugin = *NewPlugin()
// NewPlugin creates a new Plugin with the provided Options.
func NewPlugin(opts ...Option) *Plugin {
p := &Plugin{}
p.PluginName = "probe"
p.HTTP = &rest.DefaultPlugin
p.ServiceLabel = &servicelabel.DefaultPlugin
p.StatusCheck = &statuscheck.DefaultPlugin
for _, o := range opts {
o(p)
}
if p.Deps.Log == nil {
p.Deps.Log = logging.ForPlugin(p.String())
}
return p
}
// Option is a function that can be used in NewPlugin to customize Plugin.
type Option func(*Plugin)
// UseDeps returns Option that can inject custom dependencies.
func UseDeps(cb func(*Deps)) Option {
return func(p *Plugin) {
cb(&p.Deps)
}
}
// WithNonFatalPlugins defines plugins whose errors are effectively ignored
// in agent's overall status.
func WithNonFatalPlugins(plugins []string) Option {
return func(p *Plugin) {
p.NonFatalPlugins = plugins
}
}
1
https://gitee.com/xingyp/cn-infra.git
git@gitee.com:xingyp/cn-infra.git
xingyp
cn-infra
cn-infra
v2.2.0

搜索帮助