Skip to content

Commit 35d51cd

Browse files
committed
feat(server): gone notifications — synthetic delete when UPDATE leaves predicate
1 parent e910466 commit 35d51cd

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/server/notify.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ func listenForNotifications(ctx context.Context, s *server) error {
118118
continue
119119
}
120120
if !matched {
121+
// For updates: the feature was in the client's subscription but no longer matches.
122+
// Send a synthetic delete so the client removes the stale row.
123+
// For inserts: the row was never in the client's DB — nothing to remove.
124+
if payload.Op == "update" {
125+
gone := DeltaMessage{
126+
Type: "delta",
127+
Op: "delete",
128+
Feature: Feature{"id": featureID},
129+
OriginClientID: payload.OriginClientID,
130+
}
131+
if goneMsg, err := json.Marshal(gone); err == nil {
132+
select {
133+
case cand.client.send <- goneMsg:
134+
default:
135+
log.Printf("datum-server: client %s send buffer full, dropping gone notification", cand.id)
136+
}
137+
}
138+
}
121139
continue
122140
}
123141
}

0 commit comments

Comments
 (0)