···
func (h *Handle) Events(w http.ResponseWriter, r *http.Request) {
l := h.l.With("handler", "OpLog")
-
l.Info("received new connection")
conn, err := upgrader.Upgrade(w, r, nil)
···
-
l.Info("upgraded http to wss")
defer h.n.Unsubscribe(ch)
···
cursor := r.URL.Query().Get("cursor")
// complete backfill first before going to live data
-
l.Info("going through backfill", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to backfill", "err", err)
···
// wait for new data or timeout
-
l.Info("stopping stream: client closed connection")
// we have been notified of new data
-
l.Info("going through live data", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to stream", "err", err)
case <-time.After(30 * time.Second):
-
l.Info("sent keepalive")
if err = conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second)); err != nil {
l.Error("failed to write control", "err", err)
···
func (h *Handle) Events(w http.ResponseWriter, r *http.Request) {
l := h.l.With("handler", "OpLog")
+
l.Debug("received new connection")
conn, err := upgrader.Upgrade(w, r, nil)
···
+
l.Debug("upgraded http to wss")
defer h.n.Unsubscribe(ch)
···
cursor := r.URL.Query().Get("cursor")
// complete backfill first before going to live data
+
l.Debug("going through backfill", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to backfill", "err", err)
···
// wait for new data or timeout
+
l.Debug("stopping stream: client closed connection")
// we have been notified of new data
+
l.Debug("going through live data", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to stream", "err", err)
case <-time.After(30 * time.Second):
+
l.Debug("sent keepalive")
if err = conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second)); err != nil {
l.Error("failed to write control", "err", err)