当前位置: 首页>>代码示例>>Golang>>正文


Golang UnitFile.String方法代码示例

本文整理汇总了Golang中github.com/coreos/fleet/unit.UnitFile.String方法的典型用法代码示例。如果您正苦于以下问题:Golang UnitFile.String方法的具体用法?Golang UnitFile.String怎么用?Golang UnitFile.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coreos/fleet/unit.UnitFile的用法示例。


在下文中一共展示了UnitFile.String方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: storeOrGetUnitFile

func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
	um := unitModel{
		Raw: u.String(),
	}

	val, err := marshal(um)
	if err != nil {
		return err
	}

	key := r.hashedUnitPath(u.Hash())
	opts := &etcd.SetOptions{
		PrevExist: etcd.PrevNoExist,
	}
	start := time.Now()
	_, err = r.kAPI.Set(context.Background(), key, val, opts)
	// unit is already stored
	if isEtcdError(err, etcd.ErrorCodeNodeExist) {
		// TODO(jonboulle): verify more here?
		err = nil
	}
	if err != nil {
		metrics.ReportRegistryOpFailure(metrics.Set)
		return
	}
	metrics.ReportRegistryOpSuccess(metrics.Set, start)
	return
}
开发者ID:pulcy,项目名称:j2,代码行数:28,代码来源:unit.go

示例2: Load

// Load writes the given Unit to disk, subscribing to relevant dbus
// events, caching the Unit's Hash, and, if necessary, instructing the systemd
// daemon to reload.
func (m *systemdUnitManager) Load(name string, u unit.UnitFile) error {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	err := m.writeUnit(name, u.String())
	if err != nil {
		return err
	}
	m.hashes[name] = u.Hash()
	if m.unitRequiresDaemonReload(name) {
		return m.daemonReload()
	}
	return nil
}
开发者ID:ericcapricorn,项目名称:fleet,代码行数:16,代码来源:manager.go

示例3: Load

// Load writes the given Unit to disk, subscribing to relevant dbus
// events and caching the Unit's Hash.
func (m *systemdUnitManager) Load(name string, u unit.UnitFile) error {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	err := m.writeUnit(name, u.String())
	if err != nil {
		return err
	}
	if _, exists := u.Contents["Install"]; exists {
		log.Debugf("Detected [Install] section in the systemd unit (%s)", name)
		ok, err := m.enableUnit(name)
		if err != nil || !ok {
			m.removeUnit(name)
			return fmt.Errorf("Failed to enable systemd unit %s: %v", name, err)
		}
	}
	m.hashes[name] = u.Hash()
	return nil
}
开发者ID:jonboulle,项目名称:fleet,代码行数:20,代码来源:manager.go

示例4: storeOrGetUnitFile

func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
	um := unitModel{
		Raw: u.String(),
	}

	val, err := marshal(um)
	if err != nil {
		return err
	}

	key := r.hashedUnitPath(u.Hash())
	opts := &etcd.SetOptions{
		PrevExist: etcd.PrevNoExist,
	}
	_, err = r.kAPI.Set(r.ctx(), key, val, opts)
	// unit is already stored
	if isEtcdError(err, etcd.ErrorCodeNodeExist) {
		// TODO(jonboulle): verify more here?
		err = nil
	}
	return
}
开发者ID:Roskowski101,项目名称:fleet,代码行数:22,代码来源:unit.go

示例5: storeOrGetUnitFile

func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
	um := unitModel{
		Raw: u.String(),
	}

	json, err := marshal(um)
	if err != nil {
		return err
	}

	req := etcd.Create{
		Key:   r.hashedUnitPath(u.Hash()),
		Value: json,
	}
	_, err = r.etcd.Do(&req)
	// unit is already stored
	if err != nil && isNodeExist(err) {
		// TODO(jonboulle): verify more here?
		err = nil
	}
	return
}
开发者ID:hugoduncan,项目名称:fleet,代码行数:22,代码来源:unit.go


注:本文中的github.com/coreos/fleet/unit.UnitFile.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。