本文整理汇总了Golang中github.com/akutz/gofig/types.Config.GetBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.GetBool方法的具体用法?Golang Config.GetBool怎么用?Golang Config.GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/akutz/gofig/types.Config
的用法示例。
在下文中一共展示了Config.GetBool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
// Init initializes the service.
func (s *globalTaskService) Init(ctx types.Context, config gofig.Config) error {
s.tasks = map[int]*task{}
s.config = config
s.resultSchemaValidationEnabled = config.GetBool(
types.ConfigSchemaResponseValidationEnabled)
ctx.WithField("enabled", s.resultSchemaValidationEnabled).Debug(
"configured result schema validation")
return nil
}
示例2: getBool
func getBool(
config gofig.Config,
key string,
roots ...string) bool {
for _, r := range roots {
rk := strings.Replace(key, "libstorage.", fmt.Sprintf("%s.", r), 1)
if config.IsSet(rk) {
return config.GetBool(rk)
}
}
if config.IsSet(key) {
return config.GetBool(key)
}
return false
}
示例3: Init
func (d *driver) Init(ctx types.Context, config gofig.Config) error {
logFields := log.Fields{}
addr := config.GetString(types.ConfigHost)
d.ctx = ctx.WithValue(context.HostKey, addr)
d.ctx.Debug("got configured host address")
proto, lAddr, err := gotil.ParseAddress(addr)
if err != nil {
return err
}
tlsConfig, err := utils.ParseTLSConfig(
config, logFields, "libstorage.client")
if err != nil {
return err
}
host := getHost(proto, lAddr, tlsConfig)
lsxPath := config.GetString(types.ConfigExecutorPath)
cliType := types.ParseClientType(config.GetString(types.ConfigClientType))
disableKeepAlive := config.GetBool(types.ConfigHTTPDisableKeepAlive)
logFields["host"] = host
logFields["lsxPath"] = lsxPath
logFields["clientType"] = cliType
logFields["disableKeepAlive"] = disableKeepAlive
httpTransport := &http.Transport{
Dial: func(string, string) (net.Conn, error) {
if tlsConfig == nil {
return net.Dial(proto, lAddr)
}
return tls.Dial(proto, lAddr, tlsConfig)
},
DisableKeepAlives: disableKeepAlive,
}
apiClient := apiclient.New(host, httpTransport)
logReq := config.GetBool(types.ConfigLogHTTPRequests)
logRes := config.GetBool(types.ConfigLogHTTPResponses)
apiClient.LogRequests(logReq)
apiClient.LogResponses(logRes)
logFields["enableInstanceIDHeaders"] = EnableInstanceIDHeaders
logFields["enableLocalDevicesHeaders"] = EnableLocalDevicesHeaders
logFields["logRequests"] = logReq
logFields["logResponses"] = logRes
d.client = client{
APIClient: apiClient,
ctx: ctx,
config: config,
clientType: cliType,
serviceCache: &lss{Store: utils.NewStore()},
}
if d.clientType == types.IntegrationClient {
newIIDCache := utils.NewStore
dur, err := time.ParseDuration(
config.GetString(types.ConfigClientCacheInstanceID))
if err != nil {
logFields["iidCacheDuration"] = dur.String()
newIIDCache = func() types.Store {
return utils.NewTTLStore(dur, true)
}
}
d.lsxCache = &lss{Store: utils.NewStore()}
d.supportedCache = utils.NewStore()
d.instanceIDCache = &lss{Store: newIIDCache()}
}
d.ctx.WithFields(logFields).Info("created libStorage client")
if err := d.dial(ctx); err != nil {
return err
}
d.ctx.Info("successefully dialed libStorage server")
return nil
}
示例4: activateLibStorage
func activateLibStorage(
ctx apitypes.Context,
config gofig.Config) (apitypes.Context, gofig.Config, <-chan error, error) {
apiserver.DisableStartupInfo = true
var (
host string
err error
isRunning bool
errs chan error
serverErrChan <-chan error
server apitypes.Server
)
if host = config.GetString(apitypes.ConfigHost); host != "" {
if !config.GetBool(apitypes.ConfigEmbedded) {
ctx.WithField(
"host", host,
).Debug("not starting embedded server; embedded mode disabled")
return ctx, config, nil, nil
}
}
if host, isRunning = IsLocalServerActive(ctx, config); isRunning {
ctx = setHost(ctx, config, host)
ctx.WithField("host", host).Debug(
"not starting embedded server; already running")
return ctx, config, nil, nil
}
// if no host was specified then see if a set of default services need to
// be initialized
if host == "" {
ctx.Debug("host is empty; initiliazing default services")
if err = initDefaultLibStorageServices(ctx, config); err != nil {
ctx.WithError(err).Error("error initializing default services")
return ctx, config, nil, err
}
}
ctx.Debug("starting embedded libStorage server")
if server, serverErrChan, err = apiserver.Serve(ctx, config); err != nil {
ctx.WithError(err).Error("error starting libStorage server")
return ctx, config, nil, err
}
if host == "" {
host = server.Addrs()[0]
ctx.WithField("host", host).Debug("got host from new server address")
}
ctx = setHost(ctx, config, host)
errs = make(chan error)
go func() {
for err := range serverErrChan {
if err != nil {
errs <- err
}
}
if err := os.RemoveAll(SpecFilePath()); err == nil {
logHostSpec(ctx, host, "removed spec file")
}
close(errs)
}()
// write the host to the spec file so that other rex-ray invocations can
// find it, even if running as an embedded libStorage server
if err := WriteSpecFile(host); err != nil {
specFile := SpecFilePath()
if os.IsPermission(err) {
ctx.WithError(err).Errorf(
"user does not have write permissions for %s", specFile)
} else {
ctx.WithError(err).Errorf(
"error writing spec file at %s", specFile)
}
//WaitUntilLibStorageStopped(ctx, serverErrChan)
return ctx, config, errs, err
}
logHostSpec(ctx, host, "created spec file")
return ctx, config, errs, nil
}