Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Include emitter in instance state change events

  • Loading branch information...
commit d57ee3a080e3198e1bb0be10683c825abf97e968 1 parent c3549e3
Alexis Sellier cloudhead authored
Showing with 17 additions and 5 deletions.
  1. +13 −1 event.go
  2. +4 −4 event_test.go
14 event.go
View
@@ -164,8 +164,20 @@ func GetEventInfo(s Snapshot, ev *Event) (info interface{}, err error) {
fmt.Printf("error getting proctype: %s\n", err)
}
case EvInsReg, EvInsStart, EvInsExit, EvInsFail, EvInsDead:
+ var i *Instance
+
e := ev.Emitter
- info, err = GetInstance(s, e["instance"])
+ i, err = GetInstance(s, e["instance"])
+ if err != nil {
+ fmt.Printf("error getting instance: %s\n", err)
+ return
+ }
+ // XXX Find better place for this
+ e["app"] = i.AppName
+ e["rev"] = i.RevisionName
+ e["proctype"] = string(i.ProcessName)
+
+ info = i
if err != nil {
fmt.Printf("error getting instance info: %s\n", err)
8 event_test.go
View
@@ -211,25 +211,25 @@ func TestEventInstanceStateChange(t *testing.T) {
if err != nil {
t.Error(err)
}
- expectEvent(EvInsStart, "", l, t)
+ expectEvent(EvInsStart, "statemouse", l, t)
ins, err = ins.UpdateState(InsStateFailed)
if err != nil {
t.Error(err)
}
- expectEvent(EvInsFail, "", l, t)
+ expectEvent(EvInsFail, "statemouse", l, t)
ins, err = ins.UpdateState(InsStateExited)
if err != nil {
t.Error(err)
}
- expectEvent(EvInsExit, "", l, t)
+ expectEvent(EvInsExit, "statemouse", l, t)
_, err = ins.UpdateState(InsStateDead)
if err != nil {
t.Error(err)
}
- expectEvent(EvInsDead, "", l, t)
+ expectEvent(EvInsDead, "statemouse", l, t)
}
func expectEvent(etype EventType, appname string, l chan *Event, t *testing.T) {
Please sign in to comment.
Something went wrong with that request. Please try again.