func listenAndPoolUnlistens(pool *pgx.ConnPool, actionNum int) error { conn, err := pool.Acquire() if err != nil { return err } defer pool.Release(conn) err = conn.Listen("stress") if err != nil { return err } _, err = conn.WaitForNotification(100 * time.Millisecond) if err == pgx.ErrNotificationTimeout { return nil } return err }
func releaseAllConnections(pool *pgx.ConnPool, connections []*pgx.Conn) { for _, c := range connections { pool.Release(c) } }
func unlistenAndRelease(pool *pgx.ConnPool, conn *pgx.Conn, channel string) { if err := conn.Unlisten(channel); err != nil { conn.Close() } pool.Release(conn) }