本文整理汇总了Golang中github.com/juju/juju/agent.Config.MongoVersion方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.MongoVersion方法的具体用法?Golang Config.MongoVersion怎么用?Golang Config.MongoVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/agent.Config
的用法示例。
在下文中一共展示了Config.MongoVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ensureMongoService
func ensureMongoService(agentConfig agent.Config) error {
var oplogSize int
if oplogSizeString := agentConfig.Value(agent.MongoOplogSize); oplogSizeString != "" {
var err error
if oplogSize, err = strconv.Atoi(oplogSizeString); err != nil {
return errors.Annotatef(err, "invalid oplog size: %q", oplogSizeString)
}
}
var numaCtlPolicy bool
if numaCtlString := agentConfig.Value(agent.NumaCtlPreference); numaCtlString != "" {
var err error
if numaCtlPolicy, err = strconv.ParseBool(numaCtlString); err != nil {
return errors.Annotatef(err, "invalid numactl preference: %q", numaCtlString)
}
}
si, ok := agentConfig.StateServingInfo()
if !ok {
return errors.Errorf("agent config has no state serving info")
}
err := mongo.EnsureServiceInstalled(agentConfig.DataDir(),
si.StatePort,
oplogSize,
numaCtlPolicy,
agentConfig.MongoVersion(),
true,
)
return errors.Annotate(err, "cannot ensure that mongo service start/stop scripts are in place")
}
示例2: NewEnsureServerParams
// NewEnsureServerParams creates an EnsureServerParams from an agent
// configuration.
func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams, error) {
// If oplog size is specified in the agent configuration, use that.
// Otherwise leave the default zero value to indicate to EnsureServer
// that it should calculate the size.
var oplogSize int
if oplogSizeString := agentConfig.Value(agent.MongoOplogSize); oplogSizeString != "" {
var err error
if oplogSize, err = strconv.Atoi(oplogSizeString); err != nil {
return mongo.EnsureServerParams{}, fmt.Errorf("invalid oplog size: %q", oplogSizeString)
}
}
// If numa ctl preference is specified in the agent configuration, use that.
// Otherwise leave the default false value to indicate to EnsureServer
// that numactl should not be used.
var numaCtlPolicy bool
if numaCtlString := agentConfig.Value(agent.NumaCtlPreference); numaCtlString != "" {
var err error
if numaCtlPolicy, err = strconv.ParseBool(numaCtlString); err != nil {
return mongo.EnsureServerParams{}, fmt.Errorf("invalid numactl preference: %q", numaCtlString)
}
}
si, ok := agentConfig.StateServingInfo()
if !ok {
return mongo.EnsureServerParams{}, fmt.Errorf("agent config has no state serving info")
}
params := mongo.EnsureServerParams{
APIPort: si.APIPort,
StatePort: si.StatePort,
Cert: si.Cert,
PrivateKey: si.PrivateKey,
CAPrivateKey: si.CAPrivateKey,
SharedSecret: si.SharedSecret,
SystemIdentity: si.SystemIdentity,
DataDir: agentConfig.DataDir(),
OplogSize: oplogSize,
SetNumaControlPolicy: numaCtlPolicy,
Version: agentConfig.MongoVersion(),
}
return params, nil
}