本文整理汇总了Golang中github.com/coreos/fleet/job.Unit类的典型用法代码示例。如果您正苦于以下问题:Golang Unit类的具体用法?Golang Unit怎么用?Golang Unit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Unit类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateUnit
func (r *RPCRegistry) CreateUnit(j *job.Unit) error {
if DebugRPCRegistry {
defer debug.Exit_(debug.Enter_(j.Name))
}
un := j.ToPB()
_, err := r.getClient().CreateUnit(r.ctx(), &un)
return err
}
示例2: CreateUnit
func (rc *RegistryClient) CreateUnit(u *schema.Unit) error {
rUnit := job.Unit{
Name: u.Name,
Unit: *schema.MapSchemaUnitOptionsToUnitFile(u.Options),
TargetState: job.JobStateInactive,
}
if len(u.DesiredState) > 0 {
ts, err := job.ParseJobState(u.DesiredState)
if err != nil {
return err
}
rUnit.TargetState = ts
}
return rc.Registry.CreateUnit(&rUnit)
}
示例3: UnitsCheck
func UnitsCheck() check.ExtensionCheckResult {
cl, err := NewFleetClient()
if err != nil {
return handler.Error(err.Error())
}
units, err := cl.Units()
if err != nil {
return handler.Error(err.Error())
}
wrongStates := []string{}
for _, u := range units {
if u.DesiredState != u.CurrentState || u.DesiredState == "inactive" {
ju := job.Unit{Unit: *schema.MapSchemaUnitOptionsToUnitFile(u.Options)}
if !ju.IsGlobal() {
wrongStates = append(wrongStates, u.Name)
}
}
}
if len(wrongStates) == 0 {
return handler.Ok("Every untis are in their desired states")
} else {
return handler.Error(
fmt.Sprintf(
"Units in an incoherent state: %s",
strings.Join(wrongStates, ","),
),
)
}
}
示例4: suToGlobal
// suToGlobal returns whether or not a schema.Unit refers to a global unit
func suToGlobal(su schema.Unit) bool {
u := job.Unit{
Unit: *schema.MapSchemaUnitOptionsToUnitFile(su.Options),
}
return u.IsGlobal()
}