本文整理匯總了Golang中launchpad/net/juju-core/state.State.InferEndpoints方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.InferEndpoints方法的具體用法?Golang State.InferEndpoints怎麽用?Golang State.InferEndpoints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/juju-core/state.State
的用法示例。
在下文中一共展示了State.InferEndpoints方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DestroyRelation
// DestroyRelation removes the relation between the specified endpoints.
func DestroyRelation(state *state.State, args params.DestroyRelation) error {
eps, err := state.InferEndpoints(args.Endpoints)
if err != nil {
return err
}
rel, err := state.EndpointsRelation(eps...)
if err != nil {
return err
}
return rel.Destroy()
}
示例2: AddRelation
// AddRelation adds a relation between the specified endpoint names, and
// returns a map from service names to relation endpoints.
func AddRelation(state *state.State, args params.AddRelation) (params.AddRelationResults, error) {
inEps, err := state.InferEndpoints(args.Endpoints)
if err != nil {
return params.AddRelationResults{}, err
}
rel, err := state.AddRelation(inEps...)
if err != nil {
return params.AddRelationResults{}, err
}
outEps := make(map[string]charm.Relation)
for _, inEp := range inEps {
outEp, err := rel.Endpoint(inEp.ServiceName)
if err != nil {
return params.AddRelationResults{}, err
}
outEps[inEp.ServiceName] = outEp.Relation
}
return params.AddRelationResults{Endpoints: outEps}, nil
}