本文整理汇总了Golang中github.com/coreos/fleet/job.Job.UnitState方法的典型用法代码示例。如果您正苦于以下问题:Golang Job.UnitState方法的具体用法?Golang Job.UnitState怎么用?Golang Job.UnitState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/fleet/job.Job
的用法示例。
在下文中一共展示了Job.UnitState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: mapUnitToJob
func mapUnitToJob(entity *schema.Unit, mm map[string]*machine.MachineState) (*job.Job, error) {
contents, err := base64.StdEncoding.DecodeString(entity.FileContents)
if err != nil {
return nil, err
}
u, err := unit.NewUnit(string(contents))
if err != nil {
return nil, err
}
js := job.JobState(entity.CurrentState)
j := job.Job{
Name: entity.Name,
State: &js,
Unit: *u,
}
// populate a UnitState object only if the entity
// is actually reporting relevant data
if entity.Systemd != nil {
j.UnitState = &unit.UnitState{
LoadState: entity.Systemd.LoadState,
ActiveState: entity.Systemd.ActiveState,
SubState: entity.Systemd.SubState,
}
if len(entity.Systemd.MachineID) > 0 {
j.UnitState.MachineID = entity.Systemd.MachineID
}
}
return &j, nil
}
示例2: hydrateJob
func (r *EtcdRegistry) hydrateJob(j *job.Job) (err error) {
j.TargetState, err = r.jobTargetState(j.Name)
if err != nil {
return
}
j.TargetMachineID, err = r.jobTargetMachine(j.Name)
if err != nil {
return
}
j.UnitState = r.getUnitState(j.Name)
j.State = r.determineJobState(j.Name)
return
}
示例3: hydrateJob
func (r *EtcdRegistry) hydrateJob(j *job.Job) error {
tgt, err := r.jobTargetState(j.Name)
if err != nil {
return err
}
j.TargetState = tgt
j.TargetMachineID, err = r.jobTargetMachine(j.Name)
if err != nil {
return err
}
j.UnitState = r.getUnitState(j.Name)
j.State = r.determineJobState(j.Name)
return nil
}
示例4: parseJobDir
func (r *EtcdRegistry) parseJobDir(j *job.Job, dir *etcd.Node) (err error) {
var heartbeat string
for _, node := range dir.Nodes {
switch node.Key {
case r.jobTargetStatePath(j.Name):
j.TargetState, err = job.ParseJobState(node.Value)
if err != nil {
return
}
case r.jobTargetAgentPath(j.Name):
j.TargetMachineID = node.Value
case r.jobHeartbeatPath(j.Name):
heartbeat = node.Value
}
}
j.UnitState = r.getUnitState(j.Name)
js := determineJobState(j, heartbeat)
j.State = &js
return
}