Skip to content

Commit 1946456

Browse files
authored
Merge pull request #29 from sqlrsync/pingpongfix
fix: suppress ping pong messages in logs
2 parents 2f8bfbc + 5652d23 commit 1946456

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

client/subscription/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ func (m *Manager) readLoop() {
481481
}
482482

483483
var msg Message
484+
if string(data) == "PING" || string(data) == "PONG" {
485+
return
486+
}
484487
if err := json.Unmarshal(data, &msg); err != nil {
485488
m.logger.Warn("Failed to unmarshal message", zap.Error(err))
486489
continue

client/sync/coordinator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ func (c *Coordinator) executePushSubscribe() error {
861861
fmt.Println("⚠️ Warning: Could not set up pull subscription - will only push changes")
862862
} else {
863863
defer c.subManager.Close()
864-
fmt.Println("✅ Subscribed to remote updates - will pull new versions automatically")
864+
fmt.Println("✅ Subscribed to remote updates at " + time.Unix(time.Now().Unix(), 0).String() + " - will pull new versions automatically")
865865

866866
// Start goroutine to handle pull notifications
867867
go c.handlePullNotifications()
@@ -1131,7 +1131,7 @@ func (c *Coordinator) executeAutoMerge(localClient *bridge.BridgeClient, remoteC
11311131
AuthKey: authResult.AccessKey,
11321132
ReplicaID: authResult.ReplicaID,
11331133
Timeout: 8000,
1134-
PingPong: false,
1134+
PingPong: true,
11351135
Logger: c.logger.Named("merge-pull"),
11361136
Version: latestVersion,
11371137
ClientVersion: c.config.ClientVersion,

examples/earthquakes/gov.usgs.earthquakes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ URL=https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.csv
1111
URL=https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.csv
1212

1313
# Disabled so we can use file watching
14-
#SQLRSYNC_PATH=usgs.gov/earthquakes.db
14+
SQLRSYNC_PATH=usgs.gov/earthquakes.db
1515
PRIMARY_KEY=id
1616
MODE="INSERT OR REPLACE INTO"
1717
SCHEMA="time TEXT, latitude REAL, longitude REAL, depth REAL, mag REAL, magType TEXT, nst INTEGER, gap REAL, dmin REAL, rms REAL, net TEXT, id TEXT PRIMARY KEY, updated TEXT, place TEXT, type TEXT, horizontalError REAL, depthError REAL, magError REAL, magNst INTEGER, status TEXT, locationSource TEXT, magSource TEXT"
@@ -81,9 +81,9 @@ EOF
8181
sqlite3 "$FILE" "SELECT time, mag, place FROM $TABLE ORDER BY time DESC LIMIT 3;" 2>/dev/null | head -3
8282

8383
# Sync to SQLRsync server if path is configured
84-
if [ -n "$SQLRSYNC_PATH" ] && command -v sqlrsync >/dev/null 2>&1; then
84+
if [ -n "$SQLRSYNC_PATH" ] && command -v sqlrsync >/dev/null 2>&1 && [ "${new_records}" -gt 0 ]; then
8585
echo "Syncing to SQLRsync server: $SQLRSYNC_PATH"
86-
sqlrsync "$FILE" "$SQLRSYNC_PATH" -m "Added $new_records records, others updated"
86+
sqlrsync "$FILE" "$SQLRSYNC_PATH" -m "Added $new_records earthquakes"
8787
if [ $? -eq 0 ]; then
8888
echo "Successfully synced to server"
8989
else

0 commit comments

Comments
 (0)