本文整理汇总了Golang中github.com/juju/juju/status.Status类的典型用法代码示例。如果您正苦于以下问题:Golang Status类的具体用法?Golang Status怎么用?Golang Status使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Status类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetStatus
// SetStatus sets the status of the unit.
func (u *Unit) SetStatus(unitStatus status.Status, info string, data map[string]interface{}) error {
var result params.ErrorResults
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{Tag: u.tag.String(), Status: unitStatus.String(), Info: info, Data: data},
},
}
err := u.st.facade.FacadeCall("SetStatus", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例2: matchAgentStatus
func matchAgentStatus(patterns []string, agentStatus status.Status) (bool, bool, error) {
oneValidStatus := false
for _, p := range patterns {
// If the pattern isn't a known status, ignore it.
ps := status.Status(p)
if !ps.KnownAgentStatus() {
continue
}
oneValidStatus = true
if agentStatus.Matches(ps) {
return true, true, nil
}
}
return false, oneValidStatus, nil
}
示例3: SetUnitStatus
// SetUnitStatus sets the status of the unit.
func (u *Unit) SetUnitStatus(unitStatus status.Status, info string, data map[string]interface{}) error {
if u.st.facade.BestAPIVersion() < 2 {
return errors.NotImplementedf("SetUnitStatus")
}
var result params.ErrorResults
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{Tag: u.tag.String(), Status: unitStatus.String(), Info: info, Data: data},
},
}
err := u.st.facade.FacadeCall("SetUnitStatus", args, &result)
if err != nil {
return errors.Trace(err)
}
return result.OneError()
}
示例4: SetAgentStatus
// SetAgentStatus sets the status of the unit agent.
func (u *Unit) SetAgentStatus(agentStatus status.Status, info string, data map[string]interface{}) error {
var result params.ErrorResults
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{Tag: u.tag.String(), Status: agentStatus.String(), Info: info, Data: data},
},
}
setStatusFacadeCall := "SetAgentStatus"
if u.st.facade.BestAPIVersion() < 2 {
setStatusFacadeCall = "SetStatus"
}
err := u.st.facade.FacadeCall(setStatusFacadeCall, args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例5: matchWorkloadStatus
func matchWorkloadStatus(patterns []string, workloadStatus status.Status, agentStatus status.Status) (bool, bool, error) {
oneValidStatus := false
for _, p := range patterns {
// If the pattern isn't a known status, ignore it.
ps := status.Status(p)
if !ps.KnownWorkloadStatus() {
continue
}
oneValidStatus = true
// To preserve current expected behaviour, we only report on workload status
// if the agent itself is not in error.
if agentStatus != status.Error && workloadStatus.WorkloadMatches(ps) {
return true, true, nil
}
}
return false, oneValidStatus, nil
}
示例6: SetStatus
// SetStatus sets the status of the service if the passed unitName,
// corresponding to the calling unit, is of the leader.
func (s *Application) SetStatus(unitName string, serviceStatus status.Status, info string, data map[string]interface{}) error {
tag := names.NewUnitTag(unitName)
var result params.ErrorResults
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{
Tag: tag.String(),
Status: serviceStatus.String(),
Info: info,
Data: data,
},
},
}
err := s.st.facade.FacadeCall("SetApplicationStatus", args, &result)
if err != nil {
return errors.Trace(err)
}
return result.OneError()
}
示例7: SetInstanceStatus
// SetInstanceStatus sets the status for the provider instance.
func (m *Machine) SetInstanceStatus(status status.Status, message string, data map[string]interface{}) error {
var result params.ErrorResults
args := params.SetStatus{Entities: []params.EntityStatusArgs{
{Tag: m.tag.String(), Status: status.String(), Info: message, Data: data},
}}
err := m.st.facade.FacadeCall("SetInstanceStatus", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例8: SetStatus
// SetStatus sets the status of the model.
func (c *Client) SetStatus(status status.Status, message string, data map[string]interface{}) error {
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{c.modelTag.String(), status.String(), message, data},
},
}
var results params.ErrorResults
if err := c.caller.FacadeCall("SetStatus", args, &results); err != nil {
return errors.Trace(err)
}
if len(results.Results) != 1 {
return errors.Errorf("expected 1 result, got %d", len(results.Results))
}
if results.Results[0].Error != nil {
return errors.Trace(results.Results[0].Error)
}
return nil
}