File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ func (c *Client) Send(ev *Event) error {
54
54
if c .closed {
55
55
return io .ErrClosedPipe
56
56
}
57
- c .events <- ev
57
+ c .events <- ev . Clone ()
58
58
return nil
59
59
}
60
60
@@ -65,7 +65,7 @@ func (c *Client) Shutdown() {
65
65
}
66
66
67
67
// Wait blocks and waits for the client to be shutdown.
68
- // Call this is http handler threads to prevent the server from closing
68
+ // Call this in http handler threads to prevent the server from closing
69
69
// the client connection.
70
70
func (c * Client ) Wait () {
71
71
c .waiter .Wait ()
Original file line number Diff line number Diff line change @@ -132,3 +132,15 @@ func (e *Event) String() string {
132
132
fullEvent , _ := ioutil .ReadAll (e )
133
133
return string (fullEvent )
134
134
}
135
+
136
+ // Clone returns a deep copy of the event
137
+ func (e * Event ) Clone () * Event {
138
+ clone := & Event {
139
+ id : e .id ,
140
+ event : e .event ,
141
+ retry : e .retry ,
142
+ }
143
+
144
+ clone .data = append (clone .data , e .data ... )
145
+ return clone
146
+ }
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ func (s *Stream) Unsubscribe(topic string, c *Client) {
84
84
// Publish sends the event to clients that have subscribed to the given topic.
85
85
func (s * Stream ) Publish (topic string , e * Event ) {
86
86
s .listLock .RLock ()
87
- defer s .listLock .Unlock ()
87
+ defer s .listLock .RUnlock ()
88
88
89
89
for element := s .clients .Front (); element != nil ; element = element .Next () {
90
90
cli := element .Value .(* registeredClient )
You can’t perform that action at this time.
0 commit comments