Fix chat example
This commit is contained in:
@@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jackc/pgx"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
"github.com/jackc/pgx"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pool *pgx.ConnPool
|
var pool *pgx.ConnPool
|
||||||
@@ -58,10 +59,7 @@ func listen() {
|
|||||||
conn.Listen("chat")
|
conn.Listen("chat")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
notification, err := conn.WaitForNotification(time.Second)
|
notification, err := conn.WaitForNotification(context.Background())
|
||||||
if err == pgx.ErrNotificationTimeout {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "Error waiting for notification:", err)
|
fmt.Fprintln(os.Stderr, "Error waiting for notification:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user