From e57a088688a7d1ce2ae922658cb44635de5e9eac Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 17 Feb 2020 13:46:54 +0000 Subject: [PATCH] Live queries from event queries occur in the background Previously, LIVE queries as a result of an EVENT query would not be sent to the current connection. Now any LIVE queries resulting from an EVENT query will be delivered to ALL connections, regardless of where it originated. --- db/event.go | 4 ++++ db/socket.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/db/event.go b/db/event.go index 736b6947..636c7cd7 100644 --- a/db/event.go +++ b/db/event.go @@ -65,6 +65,10 @@ func (d *document) event(ctx context.Context, met method) (err error) { kind = "DELETE" } + var id = d.i.e.id + d.i.e.id = d.i.e.id + "-bg" + defer func() { d.i.e.id = id }() + vars := data.New() vars.Set(d.id, varKeyThis) vars.Set(kind, varKeyMethod) diff --git a/db/socket.go b/db/socket.go index 4ec96b83..d0e45fc3 100644 --- a/db/socket.go +++ b/db/socket.go @@ -41,6 +41,7 @@ type socket struct { func clear(id string) { go func() { sockets.Range(func(key, val interface{}) bool { + val.(*socket).clear(id + "-bg") val.(*socket).clear(id) return true }) @@ -50,6 +51,7 @@ func clear(id string) { func flush(id string) { go func() { sockets.Range(func(key, val interface{}) bool { + val.(*socket).flush(id + "-bg") val.(*socket).flush(id) return true })