-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
options.go
48 lines (39 loc) · 1.3 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2019 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0
package grpc
import (
"flag"
"fmt"
"time"
"github.com/spf13/viper"
"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/tenancy"
)
const (
remotePrefix = "grpc-storage"
remoteServer = remotePrefix + ".server"
remoteConnectionTimeout = remotePrefix + ".connection-timeout"
defaultConnectionTimeout = time.Duration(5 * time.Second)
)
func tlsFlagsConfig() tlscfg.ClientFlagsConfig {
return tlscfg.ClientFlagsConfig{
Prefix: remotePrefix,
}
}
// AddFlags adds flags for Options
func v1AddFlags(flagSet *flag.FlagSet) {
tlsFlagsConfig().AddFlags(flagSet)
flagSet.String(remoteServer, "", "The remote storage gRPC server address as host:port")
flagSet.Duration(remoteConnectionTimeout, defaultConnectionTimeout, "The remote storage gRPC server connection timeout")
}
func v1InitFromViper(cfg *Configuration, v *viper.Viper) error {
cfg.RemoteServerAddr = v.GetString(remoteServer)
var err error
cfg.RemoteTLS, err = tlsFlagsConfig().InitFromViper(v)
if err != nil {
return fmt.Errorf("failed to parse gRPC storage TLS options: %w", err)
}
cfg.RemoteConnectTimeout = v.GetDuration(remoteConnectionTimeout)
cfg.TenancyOpts = tenancy.InitFromViper(v)
return nil
}