本文整理匯總了Golang中github.com/megamsys/libgo/utils.Status類的典型用法代碼示例。如果您正苦於以下問題:Golang Status類的具體用法?Golang Status怎麽用?Golang Status使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Status類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ChangeState
func (m *Machine) ChangeState(status utils.Status) error {
log.Debugf(" change state of machine (%s, %s)", m.Name, status.String())
pons := nsqp.New()
if err := pons.Connect(meta.MC.NSQd[0]); err != nil {
return err
}
bytes, err := json.Marshal(
carton.Requests{
CatId: m.CartonsId,
Action: status.String(),
Category: carton.STATE,
CreatedAt: time.Now().Local().Format(time.RFC822),
})
if err != nil {
return err
}
log.Debugf(" pub to topic (%s, %s)", TOPIC, bytes)
if err = pons.Publish(TOPIC, bytes); err != nil {
return err
}
defer pons.Stop()
return nil
}
示例2: SetStatus
func (c *Component) SetStatus(status utils.Status) error {
LastStatusUpdate := time.Now().Local().Format(time.RFC822)
m := make(map[string][]string, 2)
m["lastsuccessstatusupdate"] = []string{LastStatusUpdate}
m["status"] = []string{status.String()}
c.Inputs.NukeAndSet(m) //just nuke the matching output key:
update_fields := make(map[string]interface{})
update_fields["Inputs"] = c.Inputs.ToString()
update_fields["Status"] = status.String()
ops := ldb.Options{
TableName: COMPBUCKET,
Pks: []string{"Id"},
Ccms: []string{},
Hosts: meta.MC.Scylla,
Keyspace: meta.MC.ScyllaKeyspace,
PksClauses: map[string]interface{}{"Id": c.Id},
CcmsClauses: make(map[string]interface{}),
}
if err := ldb.Updatedb(ops, update_fields); err != nil {
return err
}
_ = eventNotify(status)
return nil
}
示例3: SetStatus
func (m *Machine) SetStatus(status utils.Status) error {
log.Debugf(" set status[%s] of machine (%s, %s)", m.Id, m.Name, status.String())
if asm, err := carton.NewAmbly(m.CartonId); err != nil {
return err
} else if err = asm.SetStatus(status); err != nil {
return err
}
if m.Level == provision.BoxSome {
log.Debugf(" set status[%s] of machine (%s, %s)", m.Id, m.Name, status.String())
if comp, err := carton.NewComponent(m.Id); err != nil {
return err
} else if err = comp.SetStatus(status); err != nil {
return err
}
}
return nil
}
示例4: SetStatus
func (a *Ambly) SetStatus(status utils.Status) error {
js := a.getInputs()
LastStatusUpdate := time.Now().Local().Format(time.RFC822)
m := make(map[string][]string, 2)
m["lastsuccessstatusupdate"] = []string{LastStatusUpdate}
m["status"] = []string{status.String()}
js.NukeAndSet(m) //just nuke the matching output key:
a.Status = status.String()
update_fields := make(map[string]interface{})
update_fields["inputs"] = js.ToString()
update_fields["status"] = status.String()
ops := ldb.Options{
TableName: ASSEMBLYBUCKET,
Pks: []string{"id"},
Ccms: []string{"org_id"},
Hosts: meta.MC.Scylla,
Keyspace: meta.MC.ScyllaKeyspace,
Username: meta.MC.ScyllaPassword,
Password: meta.MC.ScyllaPassword,
PksClauses: map[string]interface{}{"id": a.Id},
CcmsClauses: map[string]interface{}{"org_id": a.OrgId},
}
if err := ldb.Updatedb(ops, update_fields); err != nil {
return err
}
_ = eventNotify(status)
return nil
}
示例5: EventNotify
func EventNotify(status utils.Status) error {
mi := make(map[string]string)
js := make(pairs.JsonPairs, 0)
m := make(map[string][]string, 2)
m["status"] = []string{status.String()}
m["description"] = []string{status.Description(meta.MC.Name)}
js.NukeAndSet(m) //just nuke the matching output key:
mi[constants.ASSEMBLY_ID] = meta.MC.CartonId
mi[constants.ACCOUNT_ID] = meta.MC.AccountId
mi[constants.EVENT_TYPE] = status.Event_type()
newEvent := events.NewMulti(
[]*events.Event{
&events.Event{
AccountsId: "",
EventAction: alerts.STATUS,
EventType: constants.EventUser,
EventData: alerts.EventData{M: mi, D: js.ToString()},
Timestamp: time.Now().Local(),
},
})
return newEvent.Write()
}
示例6: TestStatusString
func (ProvisionSuite) TestStatusString(c *check.C) {
var s utils.Status = "pending"
c.Assert(s.String(), check.Equals, "pending")
}