Skip to content

Commit

Permalink
Add _subject attribute to event message
Browse files Browse the repository at this point in the history
  • Loading branch information
g3kk0 committed Jul 10, 2017
1 parent 0204d35 commit cb9c784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions component.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

type Component struct {
ID string `json:"_component_id"`
Subject string `json:"_subject"`
Type string `json:"_component"`
State string `json:"_state"`
Action string `json:"_action"`
Expand All @@ -24,6 +25,9 @@ type Component struct {

func processComponent(msg *nats.Msg) {
var c Component

c.Subject = msg.Subject

if err := json.Unmarshal(msg.Data, &c); err != nil {
panic(err)
}
Expand Down
5 changes: 5 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import (

type Service struct {
ID string `json:"id"`
Subject string `json:"_subject"`
Changes []Component `json:"changes"`
}

func processService(msg *nats.Msg) {
var s Service

s.Subject = msg.Subject

if err := json.Unmarshal(msg.Data, &s); err != nil {
panic(err)
}
Expand All @@ -41,6 +45,7 @@ func processService(msg *nats.Msg) {
case "service.create.done", "service.create.error", "service.delete.done", "service.delete.error", "service.import.done", "service.import.error":
publishEvent(id, data)
// publishEvent(id, cliHangup)

time.Sleep(10 * time.Millisecond)
// Remove stream when the build completes
log.Println("Closing stream: ", id)
Expand Down

0 comments on commit cb9c784

Please sign in to comment.