本文整理匯總了Golang中github.com/juju/names.ServiceTag類的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceTag類的具體用法?Golang ServiceTag怎麽用?Golang ServiceTag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServiceTag類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BlockUntilLeadershipReleased
// BlockUntilLeadershipReleased implements the LeadershipService interface.
func (m *leadershipService) BlockUntilLeadershipReleased(serviceTag names.ServiceTag) (params.ErrorResult, error) {
if !m.authMember(serviceTag) {
return params.ErrorResult{Error: common.ServerError(common.ErrPerm)}, nil
}
if err := m.claimer.BlockUntilLeadershipReleased(serviceTag.Id()); err != nil {
return params.ErrorResult{Error: common.ServerError(err)}, nil
}
return params.ErrorResult{}, nil
}
示例2: BlockUntilLeadershipReleased
// BlockUntilLeadershipReleased implements the LeadershipService interface.
func (m *leadershipService) BlockUntilLeadershipReleased(serviceTag names.ServiceTag) (params.ErrorResult, error) {
if !m.authorizer.AuthUnitAgent() {
return params.ErrorResult{Error: common.ServerError(common.ErrPerm)}, nil
}
if err := m.LeadershipManager.BlockUntilLeadershipReleased(serviceTag.Id()); err != nil {
return params.ErrorResult{Error: common.ServerError(err)}, nil
}
return params.ErrorResult{}, nil
}
示例3: authMember
func (m *leadershipService) authMember(serviceTag names.ServiceTag) bool {
ownerTag := m.authorizer.GetAuthTag()
unitTag, ok := ownerTag.(names.UnitTag)
if !ok {
return false
}
unitId := unitTag.Id()
requireServiceId, err := names.UnitService(unitId)
if err != nil {
return false
}
return serviceTag.Id() == requireServiceId
}
示例4: getService
func (u *UniterAPI) getService(tag names.ServiceTag) (*state.Service, error) {
return u.st.Service(tag.Id())
}
示例5: HandleLatest
// HandleLatest implements apiserver/charmrevisionupdater.LatestCharmHandler
// by storing the charm's resources in state.
func (handler LatestCharmHandler) HandleLatest(serviceID names.ServiceTag, info charmstore.CharmInfo) error {
if err := handler.store.SetCharmStoreResources(serviceID.Id(), info.LatestResources, info.Timestamp); err != nil {
return errors.Trace(err)
}
return nil
}