本文整理匯總了Golang中github.com/coreos/fleet/job.ScheduledUnit類的典型用法代碼示例。如果您正苦於以下問題:Golang ScheduledUnit類的具體用法?Golang ScheduledUnit怎麽用?Golang ScheduledUnit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ScheduledUnit類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ScheduledUnit
// ScheduledUnit retrieves the ScheduledUnit by the given name from the Registry.
// Returns nil if no such ScheduledUnit exists, and any error encountered.
func (r *EtcdRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error) {
key := r.prefixed(jobPrefix, name)
opts := &etcd.GetOptions{
Recursive: true,
}
res, err := r.kAPI.Get(r.ctx(), key, opts)
if err != nil {
if isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
err = nil
}
return nil, err
}
su := job.ScheduledUnit{
Name: name,
TargetMachineID: dirToTargetMachineID(res.Node),
}
var us *unit.UnitState
if len(su.TargetMachineID) > 0 {
us, err = r.getUnitState(name, su.TargetMachineID)
if err != nil {
return nil, err
}
}
js := determineJobState(dirToHeartbeat(res.Node), su.TargetMachineID, us)
su.State = &js
return &su, nil
}
示例2: ScheduledUnit
// ScheduledUnit retrieves the ScheduledUnit by the given name from the Registry.
// Returns nil if no such ScheduledUnit exists, and any error encountered.
func (r *EtcdRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error) {
req := etcd.Get{
Key: path.Join(r.keyPrefix, jobPrefix, name),
Recursive: true,
}
res, err := r.etcd.Do(&req)
if err != nil {
if isKeyNotFound(err) {
err = nil
}
return nil, err
}
su := job.ScheduledUnit{
Name: name,
TargetMachineID: dirToTargetMachineID(res.Node),
}
var us *unit.UnitState
if len(su.TargetMachineID) > 0 {
us, err = r.getUnitState(name, su.TargetMachineID)
if err != nil {
return nil, err
}
}
js := determineJobState(dirToHeartbeat(res.Node), su.TargetMachineID, us)
su.State = &js
return &su, nil
}