projects
/
arvados.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5a420be
)
8460: Send selected old/new attributes with v0 events.
author
Tom Clegg <tom@curoverse.com>
Tue, 15 Nov 2016 21:30:01 +0000
(16:30 -0500)
committer
Tom Clegg <tom@curoverse.com>
Tue, 15 Nov 2016 21:30:01 +0000
(16:30 -0500)
services/ws/session_v0.go
patch
|
blob
|
history
diff --git
a/services/ws/session_v0.go
b/services/ws/session_v0.go
index 467d156ee59dadf2a4198659572d3e09e06e96e1..3894e30314461c77cb89467fbef35cc8abd6d87f 100644
(file)
--- a/
services/ws/session_v0.go
+++ b/
services/ws/session_v0.go
@@
-12,6
+12,8
@@
import (
var (
errQueueFull = errors.New("client queue full")
errFrameTooBig = errors.New("frame too big")
var (
errQueueFull = errors.New("client queue full")
errFrameTooBig = errors.New("frame too big")
+
+ sendObjectAttributes = []string{"state", "name"}
)
type sessionV0 struct {
)
type sessionV0 struct {
@@
-136,6
+138,22
@@
func (sess *sessionV0) EventMessage(e *event) ([]byte, error) {
}
if detail.Properties != nil && detail.Properties["text"] != nil {
msg["properties"] = detail.Properties
}
if detail.Properties != nil && detail.Properties["text"] != nil {
msg["properties"] = detail.Properties
+ } else {
+ msgProps := map[string]map[string]interface{}{}
+ for _, ak := range []string{"old_attributes", "new_attributes"} {
+ eventAttrs, ok := detail.Properties[ak].(map[string]interface{})
+ if !ok {
+ continue
+ }
+ msgAttrs := map[string]interface{}{}
+ for _, k := range sendObjectAttributes {
+ if v, ok := eventAttrs[k]; ok {
+ msgAttrs[k] = v
+ }
+ }
+ msgProps[ak] = msgAttrs
+ }
+ msg["properties"] = msgProps
}
return json.Marshal(msg)
}
}
return json.Marshal(msg)
}