Skip to content

Commit

Permalink
minor, see prev commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Oct 28, 2023
1 parent e75bffa commit 979ffb5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion db_table_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package pg
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"sync/atomic"
)

Expand Down Expand Up @@ -111,8 +113,12 @@ func (db *DB) ListenTable(ctx context.Context, table string, callback func(Table
for {
var evt TableNotificationJSON

notification, err := conn.Accept(context.Background())
notification, err := conn.Accept(ctx)
if err != nil {
if errors.Is(err, io.ErrUnexpectedEOF) {
return // may produced by close.
}

if callback(evt, err) != nil {
return
}
Expand Down

0 comments on commit 979ffb5

Please sign in to comment.