本文整理匯總了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()
}