38 lines
544 B
Go
38 lines
544 B
Go
package rep
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func (rep *Replicator) runWALRecvr() {
|
|
go func() {
|
|
<-rep.stop
|
|
rep.client.Close()
|
|
}()
|
|
|
|
defer rep.done.Done()
|
|
|
|
for {
|
|
rep.runWALRecvrOnce()
|
|
select {
|
|
case <-rep.stop:
|
|
log.Print("[WAL-RECVR] Stopped")
|
|
return
|
|
default:
|
|
time.Sleep(time.Second)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (rep *Replicator) runWALRecvrOnce() {
|
|
logf := func(pattern string, args ...any) {
|
|
log.Printf("[WAL-RECVR] "+pattern, args...)
|
|
}
|
|
|
|
err := rep.client.StreamWAL(rep.wal)
|
|
if !rep.stopped() {
|
|
logf("Recv failed: %v", err)
|
|
}
|
|
}
|