Skip to content

Commit f7ef6b8

Browse files
committed
Remove grace for now
Updates #209
1 parent b307b47 commit f7ef6b8

File tree

6 files changed

+15
-144
lines changed

6 files changed

+15
-144
lines changed

Diff for: conn_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,11 @@ func TestWasm(t *testing.T) {
271271
t.Skip("skipping on CI")
272272
}
273273

274-
var g websocket.Grace
275-
defer g.Close()
276-
s := httptest.NewServer(g.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
274+
// TODO grace
275+
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
277276
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
278-
Subprotocols: []string{"echo"},
279-
InsecureSkipVerify: true,
277+
Subprotocols: []string{"echo"},
278+
OriginPatterns: []string{"*"},
280279
})
281280
if err != nil {
282281
t.Errorf("echo server failed: %v", err)
@@ -291,7 +290,7 @@ func TestWasm(t *testing.T) {
291290
t.Errorf("echo server failed: %v", err)
292291
return
293292
}
294-
})))
293+
}))
295294
defer s.Close()
296295

297296
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)

Diff for: examples/chat/chat_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@ func setupTest(t *testing.T) (url string, closeFn func()) {
130130
cs.subscriberMessageBuffer = 4096
131131
cs.publishLimiter.SetLimit(rate.Inf)
132132

133-
var g websocket.Grace
134-
s := httptest.NewServer(g.Handler(cs))
133+
// TODO grace
134+
s := httptest.NewServer(cs)
135135
return s.URL, func() {
136136
s.Close()
137-
g.Close()
138137
}
139138
}
140139

Diff for: examples/chat/main.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"os"
1010
"os/signal"
1111
"time"
12-
13-
"nhooyr.io/websocket"
1412
)
1513

1614
func main() {
@@ -36,9 +34,9 @@ func run() error {
3634
log.Printf("listening on http://%v", l.Addr())
3735

3836
cs := newChatServer()
39-
var g websocket.Grace
37+
// TODO grace
4038
s := http.Server{
41-
Handler: g.Handler(cs),
39+
Handler: cs,
4240
ReadTimeout: time.Second * 10,
4341
WriteTimeout: time.Second * 10,
4442
}
@@ -59,8 +57,5 @@ func run() error {
5957
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
6058
defer cancel()
6159

62-
s.Shutdown(ctx)
63-
g.Shutdown(ctx)
64-
65-
return nil
60+
return s.Shutdown(ctx)
6661
}

Diff for: examples/echo/echo.go renamed to examples/echo/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
// This example starts a WebSocket echo server,
2525
// dials the server and then sends 5 different messages
2626
// and prints out the server's responses.
27-
func Example_echo() {
27+
func main() {
2828
// First we listen on port 0 which means the OS will
2929
// assign us a random free port. This is the listener
3030
// the server will serve on and the client will connect to.
@@ -34,15 +34,14 @@ func Example_echo() {
3434
}
3535
defer l.Close()
3636

37-
var g websocket.Grace
38-
defer g.Close()
37+
// TODO grace
3938
s := &http.Server{
40-
Handler: g.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
39+
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
4140
err := echoServer(w, r)
4241
if err != nil {
4342
log.Printf("echo server: %v", err)
4443
}
45-
})),
44+
}),
4645
ReadTimeout: time.Second * 15,
4746
WriteTimeout: time.Second * 15,
4847
}
@@ -61,6 +60,7 @@ func Example_echo() {
6160
if err != nil {
6261
log.Fatalf("client failed: %v", err)
6362
}
63+
6464
// Output:
6565
// received: map[i:0]
6666
// received: map[i:1]

Diff for: grace.go

-120
This file was deleted.

Diff for: ws_js.go

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ type Conn struct {
3939
readSignal chan struct{}
4040
readBufMu sync.Mutex
4141
readBuf []wsjs.MessageEvent
42-
43-
g *Grace
4442
}
4543

4644
func (c *Conn) close(err error, wasClean bool) {

0 commit comments

Comments
 (0)