本文整理汇总了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
}