Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

feat: Add DialCache for key-based connection caching#391

Merged
kylecarbs merged 7 commits intomasterfromcache
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add WS options to dial
  • Loading branch information
@kylecarbs
kylecarbs committedJul 21, 2021
commit6aa80482fcce34aba5c7281aa79417efc0fb5433
1 change: 1 addition & 0 deletionsinternal/cmd/tunnel.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,6 +112,7 @@ func (c *tunnneler) start(ctx context.Context) error {
TURNProxyURL: c.brokerAddr,
ICEServers: []webrtc.ICEServer{wsnet.TURNProxyICECandidate()},
},
nil,
)
if err != nil {
return xerrors.Errorf("creating workspace dialer: %w", err)
Expand Down
2 changes: 1 addition & 1 deletionwsnet/cache_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@ import (
func TestCache(t *testing.T) {
dialFunc := func(connectAddr string) func() (*Dialer, error) {
return func() (*Dialer, error) {
return DialWebsocket(context.Background(), connectAddr, nil)
return DialWebsocket(context.Background(), connectAddr, nil, nil)
}
}

Expand Down
6 changes: 3 additions & 3 deletionswsnet/dial.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,8 +35,8 @@ type DialOptions struct {
}

// DialWebsocket dials the broker with a WebSocket and negotiates a connection.
func DialWebsocket(ctx context.Context, broker string,options *DialOptions) (*Dialer, error) {
conn, resp, err := websocket.Dial(ctx, broker,nil)
func DialWebsocket(ctx context.Context, broker string,netOpts *DialOptions, wsOpts *websocket.DialOptions) (*Dialer, error) {
conn, resp, err := websocket.Dial(ctx, broker,wsOpts)
if err != nil {
if resp != nil {
defer func() {
Expand All@@ -52,7 +52,7 @@ func DialWebsocket(ctx context.Context, broker string, options *DialOptions) (*D
// We should close the socket intentionally.
_ = conn.Close(websocket.StatusInternalError, "an error occurred")
}()
return Dial(nconn,options)
return Dial(nconn,netOpts)
}

// Dial negotiates a connection to a listener.
Expand Down
22 changes: 11 additions & 11 deletionswsnet/dial_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,7 +39,7 @@ func ExampleDial_basic() {

dialer, err := DialWebsocket(context.Background(), "wss://master.cdr.dev/agent/workspace/connect", &DialOptions{
ICEServers: servers,
})
}, nil)
if err != nil {
// Do something...
}
Expand All@@ -60,7 +60,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)

err = dialer.Ping(context.Background())
Expand All@@ -83,7 +83,7 @@ func TestDial(t *testing.T) {
Credential: testPass,
CredentialType: webrtc.ICECredentialTypePassword,
}},
})
}, nil)
require.NoError(t, err)

_ = dialer.Ping(context.Background())
Expand All@@ -100,7 +100,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)

_, err = dialer.DialContext(context.Background(), "tcp", "localhost:100")
Expand DownExpand Up@@ -130,7 +130,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)

conn, err := dialer.DialContext(context.Background(), listener.Addr().Network(), listener.Addr().String())
Expand DownExpand Up@@ -158,7 +158,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)

conn, err := dialer.DialContext(context.Background(), listener.Addr().Network(), listener.Addr().String())
Expand All@@ -178,7 +178,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)

err = dialer.Close()
Expand DownExpand Up@@ -210,7 +210,7 @@ func TestDial(t *testing.T) {
Credential: testPass,
CredentialType: webrtc.ICECredentialTypePassword,
}},
})
}, nil)
require.NoError(t, err)

conn, err := dialer.DialContext(context.Background(), "tcp", tcpListener.Addr().String())
Expand All@@ -231,7 +231,7 @@ func TestDial(t *testing.T) {
require.NoError(t, err)
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
require.NoError(t, err)
go func() {
_ = dialer.Close()
Expand DownExpand Up@@ -261,7 +261,7 @@ func TestDial(t *testing.T) {
t.Error(err)
return
}
dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
if err != nil {
t.Error(err)
}
Expand DownExpand Up@@ -314,7 +314,7 @@ func BenchmarkThroughput(b *testing.B) {
}
defer l.Close()

dialer, err := DialWebsocket(context.Background(), connectAddr, nil)
dialer, err := DialWebsocket(context.Background(), connectAddr, nil, nil)
if err != nil {
b.Error(err)
return
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp