Update pinecone demo

This commit is contained in:
Neil Alexander 2021-05-24 11:17:32 +01:00
parent 2948ffd782
commit d2d2164025
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
3 changed files with 15 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"net" "net"
"net/http" "net/http"
"strings" "strings"
"time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/matrix-org/dendrite/setup" "github.com/matrix-org/dendrite/setup"
@ -16,15 +17,24 @@ import (
func ConnectToPeer(pRouter *pineconeRouter.Router, peer string) error { func ConnectToPeer(pRouter *pineconeRouter.Router, peer string) error {
var parent net.Conn var parent net.Conn
dialer := net.Dialer{
Timeout: time.Second * 5,
KeepAlive: time.Second * 5,
}
if strings.HasPrefix(peer, "ws://") || strings.HasPrefix(peer, "wss://") { if strings.HasPrefix(peer, "ws://") || strings.HasPrefix(peer, "wss://") {
c, _, err := websocket.DefaultDialer.Dial(peer, nil) wsdialer := websocket.Dialer{
NetDial: dialer.Dial,
NetDialContext: dialer.DialContext,
HandshakeTimeout: time.Second * 5,
}
c, _, err := wsdialer.Dial(peer, nil)
if err != nil { if err != nil {
return fmt.Errorf("websocket.DefaultDialer.Dial: %w", err) return fmt.Errorf("websocket.DefaultDialer.Dial: %w", err)
} }
parent = WrapWebSocketConn(c) parent = WrapWebSocketConn(c)
} else { } else {
var err error var err error
parent, err = net.Dial("tcp", peer) parent, err = dialer.Dial("tcp", peer)
if err != nil { if err != nil {
return fmt.Errorf("net.Dial: %w", err) return fmt.Errorf("net.Dial: %w", err)
} }

2
go.mod
View File

@ -25,7 +25,7 @@ require (
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
github.com/matrix-org/gomatrixserverlib v0.0.0-20210302161955-6142fe3f8c2c github.com/matrix-org/gomatrixserverlib v0.0.0-20210302161955-6142fe3f8c2c
github.com/matrix-org/naffka v0.0.0-20201009174903-d26a3b9cb161 github.com/matrix-org/naffka v0.0.0-20201009174903-d26a3b9cb161
github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646

2
go.sum
View File

@ -712,6 +712,8 @@ github.com/matrix-org/pinecone v0.0.0-20210518145819-76f42940e9b9 h1:foRhM2ZUQ46
github.com/matrix-org/pinecone v0.0.0-20210518145819-76f42940e9b9/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA= github.com/matrix-org/pinecone v0.0.0-20210518145819-76f42940e9b9/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 h1:OflgibJOmt1WvP5TxEES0i1dHj40K+pwmtQ155hZQX8= github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 h1:OflgibJOmt1WvP5TxEES0i1dHj40K+pwmtQ155hZQX8=
github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA= github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438 h1:pfYBf8db9X8fsieJOUZqv6Evz6YByP+n9rOTzTPC66U=
github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U= github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 h1:eCEHXWDv9Rm335MSuB49mFUK44bwZPFSDde3ORE3syk= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 h1:eCEHXWDv9Rm335MSuB49mFUK44bwZPFSDde3ORE3syk=
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=