Skip to content

Commit

Permalink
Remove grace for now
Browse files Browse the repository at this point in the history
Updates #209
  • Loading branch information
nhooyr committed Apr 14, 2020
1 parent b307b47 commit f7ef6b8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 144 deletions.
11 changes: 5 additions & 6 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,11 @@ func TestWasm(t *testing.T) {
t.Skip("skipping on CI")
}

var g websocket.Grace
defer g.Close()
s := httptest.NewServer(g.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// TODO grace
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
Subprotocols: []string{"echo"},
InsecureSkipVerify: true,
Subprotocols: []string{"echo"},
OriginPatterns: []string{"*"},
})
if err != nil {
t.Errorf("echo server failed: %v", err)
Expand All @@ -291,7 +290,7 @@ func TestWasm(t *testing.T) {
t.Errorf("echo server failed: %v", err)
return
}
})))
}))
defer s.Close()

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
Expand Down
5 changes: 2 additions & 3 deletions examples/chat/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ func setupTest(t *testing.T) (url string, closeFn func()) {
cs.subscriberMessageBuffer = 4096
cs.publishLimiter.SetLimit(rate.Inf)

var g websocket.Grace
s := httptest.NewServer(g.Handler(cs))
// TODO grace
s := httptest.NewServer(cs)
return s.URL, func() {
s.Close()
g.Close()
}
}

Expand Down
11 changes: 3 additions & 8 deletions examples/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"os"
"os/signal"
"time"

"nhooyr.io/websocket"
)

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

cs := newChatServer()
var g websocket.Grace
// TODO grace
s := http.Server{
Handler: g.Handler(cs),
Handler: cs,
ReadTimeout: time.Second * 10,
WriteTimeout: time.Second * 10,
}
Expand All @@ -59,8 +57,5 @@ func run() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

s.Shutdown(ctx)
g.Shutdown(ctx)

return nil
return s.Shutdown(ctx)
}
10 changes: 5 additions & 5 deletions examples/echo/echo.go → examples/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// This example starts a WebSocket echo server,
// dials the server and then sends 5 different messages
// and prints out the server's responses.
func Example_echo() {
func main() {
// First we listen on port 0 which means the OS will
// assign us a random free port. This is the listener
// the server will serve on and the client will connect to.
Expand All @@ -34,15 +34,14 @@ func Example_echo() {
}
defer l.Close()

var g websocket.Grace
defer g.Close()
// TODO grace
s := &http.Server{
Handler: g.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := echoServer(w, r)
if err != nil {
log.Printf("echo server: %v", err)
}
})),
}),
ReadTimeout: time.Second * 15,
WriteTimeout: time.Second * 15,
}
Expand All @@ -61,6 +60,7 @@ func Example_echo() {
if err != nil {
log.Fatalf("client failed: %v", err)
}

// Output:
// received: map[i:0]
// received: map[i:1]
Expand Down
120 changes: 0 additions & 120 deletions grace.go

This file was deleted.

2 changes: 0 additions & 2 deletions ws_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ type Conn struct {
readSignal chan struct{}
readBufMu sync.Mutex
readBuf []wsjs.MessageEvent

g *Grace
}

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

0 comments on commit f7ef6b8

Please sign in to comment.