本文整理匯總了Golang中github.com/hawkular/hawkular-client-go/metrics.Parameters.Concurrency方法的典型用法代碼示例。如果您正苦於以下問題:Golang Parameters.Concurrency方法的具體用法?Golang Parameters.Concurrency怎麽用?Golang Parameters.Concurrency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hawkular/hawkular-client-go/metrics.Parameters
的用法示例。
在下文中一共展示了Parameters.Concurrency方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func (h *hawkularSink) init() error {
h.reg = make(map[string]*metrics.MetricDefinition)
h.models = make(map[string]*metrics.MetricDefinition)
h.modifiers = make([]metrics.Modifier, 0)
h.filters = make([]Filter, 0)
h.batchSize = batchSizeDefault
p := metrics.Parameters{
Tenant: "heapster",
Url: h.uri.String(),
Concurrency: concurrencyDefault,
}
opts := h.uri.Query()
if v, found := opts["tenant"]; found {
p.Tenant = v[0]
}
if v, found := opts["labelToTenant"]; found {
h.labelTenant = v[0]
}
if v, found := opts[nodeId]; found {
h.labelNodeId = v[0]
}
if v, found := opts["useServiceAccount"]; found {
if b, _ := strconv.ParseBool(v[0]); b {
// If a readable service account token exists, then use it
if contents, err := ioutil.ReadFile(defaultServiceAccountFile); err == nil {
p.Token = string(contents)
}
}
}
// Authentication / Authorization parameters
tC := &tls.Config{}
if v, found := opts["auth"]; found {
if _, f := opts["caCert"]; f {
return fmt.Errorf("Both auth and caCert files provided, combination is not supported")
}
if len(v[0]) > 0 {
// Authfile
kubeConfig, err := kubeClientCmd.NewNonInteractiveDeferredLoadingClientConfig(&kubeClientCmd.ClientConfigLoadingRules{
ExplicitPath: v[0]},
&kubeClientCmd.ConfigOverrides{}).ClientConfig()
if err != nil {
return err
}
tC, err = kube_client.TLSConfigFor(kubeConfig)
if err != nil {
return err
}
}
}
if u, found := opts["user"]; found {
if _, wrong := opts["useServiceAccount"]; wrong {
return fmt.Errorf("If user and password are used, serviceAccount cannot be used")
}
if p, f := opts["pass"]; f {
h.modifiers = append(h.modifiers, func(req *http.Request) error {
req.SetBasicAuth(u[0], p[0])
return nil
})
}
}
if v, found := opts["caCert"]; found {
caCert, err := ioutil.ReadFile(v[0])
if err != nil {
return err
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tC.RootCAs = caCertPool
}
if v, found := opts["insecure"]; found {
_, f := opts["caCert"]
_, f2 := opts["auth"]
if f || f2 {
return fmt.Errorf("Insecure can't be defined with auth or caCert")
}
insecure, err := strconv.ParseBool(v[0])
if err != nil {
return err
}
tC.InsecureSkipVerify = insecure
}
p.TLSConfig = tC
// Filters
if v, found := opts["filter"]; found {
filters, err := parseFilters(v)
//.........這裏部分代碼省略.........