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