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


Golang Operation.GetURI方法代码示例

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


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

示例1: StartService

// StartService starts the specified service. The operation parameter is used
// for the context of the start; the service's URI, the referrer, signaling
// completion of the service start, etc.
//
// Upon returning, either the operation has failed, or the service is still
// going through the motions of being started. In the latter case, the caller
// can wait for completion of the operation to ensure the service is fully
// started.
//
func (h *ServiceHost) StartService(op *operation.Operation, s Service) {
	s.SetHost(h)

	// The selflink is expected to be either set on the service externally
	// (before starting the service), or as the URI path on the operation.
	selfLink := s.SelfLink()
	if selfLink == "" {
		// Prefix path with / to make sure it is absolute.
		// The clean function removes double /'s and the trailing /, if any.
		selfLink = path.Clean("/" + op.GetURI().Path)
		s.SetSelfLink(selfLink)
	}

	// Add service to the host's service map.
	h.Lock()
	_, ok := h.services[selfLink]
	if ok {
		h.Unlock()
		op.Fail(errors.New("host: service is already bound"))
		return
	}
	h.services[selfLink] = s
	h.Unlock()

	// Service is now attached to host; move to initialized state.
	if err := s.SetStage(StageInitialized); err != nil {
		op.Fail(err)
		return
	}

	// Start service asynchronously.
	go h.startService(op, s)
}
开发者ID:vmware,项目名称:xenon,代码行数:42,代码来源:service_host.go


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