aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.go11
-rw-r--r--main.go6
-rw-r--r--wrms.go4
3 files changed, 7 insertions, 14 deletions
diff --git a/connection.go b/connection.go
index 4901fdd..e16c942 100644
--- a/connection.go
+++ b/connection.go
@@ -67,12 +67,11 @@ func (c *Connection) Send(ev Event) {
c.refs.Add(-1)
}
-func (conn *Connection) _send(evs []interface{}) error {
+func (conn *Connection) _send(evs []interface{}) {
for _, ev := range evs {
data, err := json.Marshal(ev)
if err != nil {
- llog.Warning("Encoding the initial command %v failed with %s", ev, err)
- return err
+ llog.Fatal("Encoding the initial command %v failed with %s", ev, err)
}
sdata := string(data)
@@ -80,12 +79,10 @@ func (conn *Connection) _send(evs []interface{}) error {
fmt.Fprintf(conn.w, "data: %s\n\n", sdata)
conn.flusher.Flush()
}
-
- return nil
}
-func (conn *Connection) _sendEv(ev Event) error {
- return conn._send([]interface{}{ev})
+func (conn *Connection) _sendEv(ev Event) {
+ conn._send([]interface{}{ev})
}
func (conn *Connection) serve() {
diff --git a/main.go b/main.go
index 0b9b956..c2642f7 100644
--- a/main.go
+++ b/main.go
@@ -243,11 +243,7 @@ func eventsEndpoint(w http.ResponseWriter, r *http.Request) {
}()
llog.Info("New SSE connection with id %v", connId)
- err = wrms.initConn(conn)
- if err != nil {
- return
- }
-
+ wrms.initConn(conn)
conn.serve()
}
diff --git a/wrms.go b/wrms.go
index b2bc2dc..41d7549 100644
--- a/wrms.go
+++ b/wrms.go
@@ -77,7 +77,7 @@ func (wrms *Wrms) delConn(conn *Connection) {
}
}
-func (wrms *Wrms) initConn(conn *Connection) error {
+func (wrms *Wrms) initConn(conn *Connection) {
wrms.rwlock.RLock()
curEventId := wrms.eventId.Load()
@@ -123,7 +123,7 @@ func (wrms *Wrms) initConn(conn *Connection) error {
wrms.rwlock.RUnlock()
llog.Info("Sending initial cmds %v", initialCmds)
- return conn._send(initialCmds)
+ conn._send(initialCmds)
}
func (wrms *Wrms) GetConn(connId uuid.UUID) *Connection {