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

Rewrite with compression support#163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nhooyr merged 56 commits intomasterfromcompress
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
56 commits
Select commitHold shift + click to select a range
8604dee
Increase TestWASM timeout
nhooyrOct 15, 2019
e55ac18
Document compression API
nhooyrOct 14, 2019
e142e08
Improve compression docs
nhooyrNov 12, 2019
53c1aea
Implement compression extension negotiation
nhooyrNov 12, 2019
2cf6c28
Implement compression writer and reader pooling
nhooyrNov 12, 2019
a01afea
Support x-webkit-deflate-frame extension for Safari
nhooyrNov 12, 2019
531d4fa
Improve general compression API and write docs
nhooyrNov 12, 2019
d0a8049
Rewrite core
nhooyrNov 19, 2019
dd107dd
Update CI
nhooyrNov 28, 2019
6c6b8e9
Cleanup wspb and wsjson
nhooyrNov 28, 2019
6b782a3
Run make fmt
nhooyrNov 28, 2019
989ba2f
Change websocket to WebSocket in docs/errors
nhooyrNov 28, 2019
9f15963
Simplify dial.go
nhooyrNov 28, 2019
120911b
Remove use of math/rand.Init
nhooyrNov 28, 2019
7ad1514
Update README.md comparison
nhooyrNov 29, 2019
746140b
Further improve README
nhooyrNov 29, 2019
43cb01e
Refactor read.go/write.go
nhooyrNov 29, 2019
e8dfe27
Make CI pass
nhooyrNov 29, 2019
f6137f3
Add minor improvements
nhooyrDec 6, 2019
6f6fa43
Refactor autobahn
nhooyrDec 31, 2019
8c87970
Add slidingWindowReader
nhooyrJan 4, 2020
aaf4b45
Up test coverage of accept.go to 100%
nhooyrJan 26, 2020
6b76536
Up dial coverage to 100%
nhooyrJan 30, 2020
0f115ed
Add Go 1.12 support
nhooyrJan 31, 2020
b6b56b7
Both modes seem to work :)
nhooyrFeb 5, 2020
9e32354
Fix randString method in tests
nhooyrFeb 6, 2020
78da35e
Get test with multiple messages working
nhooyrFeb 7, 2020
d092686
Autobahn tests fully pass :)
nhooyrFeb 8, 2020
6975801
Fix race in tests
nhooyrFeb 9, 2020
bbaf469
Fix test step
nhooyrFeb 9, 2020
faadcc9
Simplify tests
nhooyrFeb 9, 2020
3f2589f
Remove quite a bit of slog
nhooyrFeb 9, 2020
b53f306
Get Wasm tests working
nhooyrFeb 9, 2020
69ff675
More tests and fixes
nhooyrFeb 9, 2020
085e671
Get coverage to 85%
nhooyrFeb 9, 2020
51769b3
Add wspb test
nhooyrFeb 9, 2020
670be05
Merge in handshake improvements from master
nhooyrFeb 9, 2020
988b8f2
Merge remote-tracking branch 'origin/master' into compress
nhooyrFeb 9, 2020
3a526d8
Fix bug in closeHandshake
nhooyrFeb 9, 2020
999b812
Fix race in msgReader
nhooyrFeb 9, 2020
4b84d25
Fix a race with c.closed
nhooyrFeb 9, 2020
85f249d
Up timeouts
nhooyrFeb 9, 2020
6b38ebb
Test fixes
nhooyrFeb 9, 2020
6770421
Fix goroutine leak from deadlock when closing
nhooyrFeb 12, 2020
c752365
Make flateThreshold work
nhooyrFeb 12, 2020
0ea9466
Cleanup writeMu and flateThreshold
nhooyrFeb 12, 2020
b33d48c
Minor cleanup
nhooyrFeb 12, 2020
9c5bfab
Simplifications of conn_test.go
nhooyrFeb 13, 2020
3673c2c
Use basic test assertions
nhooyrFeb 13, 2020
c5b0a00
Fix badPing test duration
nhooyrFeb 13, 2020
1c7c14e
Pool sliding windows
nhooyrFeb 13, 2020
503b469
Simplify sliding window API
nhooyrFeb 13, 2020
dff4af3
Add conn benchmark
nhooyrFeb 13, 2020
2377cca
Switch to klauspost/compress
nhooyrFeb 15, 2020
d57b253
Report how efficient compression is in BenchmarkConn
nhooyrFeb 16, 2020
1bc100d
Update docs and random little issues
nhooyrFeb 16, 2020
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
Cleanup wspb and wsjson
  • Loading branch information
@nhooyr
nhooyr committedNov 29, 2019
commit6c6b8e9af2030e9ce4352ae006092255ca62fef5
45 changes: 0 additions & 45 deletions.github/CONTRIBUTING.md
View file
Open in desktop

This file was deleted.

1 change: 0 additions & 1 deletion.github/ISSUE_TEMPLATE.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
<!--
Please be as descriptive as possible.
Reproducible examples are key to finding and fixing bugs.
-->
4 changes: 0 additions & 4 deletions.github/PULL_REQUEST_TEMPLATE.md
View file
Open in desktop

This file was deleted.

4 changes: 0 additions & 4 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,10 +165,6 @@ faster, the compression extensions are fully supported and as much as possible i

See the gorilla/websocket comparison for more performance details.

## Contributing

See [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md).

## Users

If your company or project is using this library, feel free to open an issue or PR to amend this list.
Expand Down
12 changes: 6 additions & 6 deletionsassert_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ func assertJSONEcho(t *testing.T, ctx context.Context, c *websocket.Conn, n int)
err = wsjson.Read(ctx, c, &act)
assert.Success(t, err)

assert.Equalf(t, exp, act, "unexpected JSON")
assert.Equal(t, exp, act, "unexpected JSON")
}

func assertJSONRead(t *testing.T, ctx context.Context, c *websocket.Conn, exp interface{}) {
Expand All@@ -43,7 +43,7 @@ func assertJSONRead(t *testing.T, ctx context.Context, c *websocket.Conn, exp in
err := wsjson.Read(ctx, c, &act)
assert.Success(t, err)

assert.Equalf(t, exp, act, "unexpected JSON")
assert.Equal(t, exp, act, "unexpected JSON")
}

func randString(n int) string {
Expand All@@ -69,18 +69,18 @@ func assertEcho(t *testing.T, ctx context.Context, c *websocket.Conn, typ websoc
typ2, p2, err := c.Read(ctx)
assert.Success(t, err)

assert.Equalf(t, typ, typ2, "unexpected data type")
assert.Equalf(t, p, p2, "unexpected payload")
assert.Equal(t, typ, typ2, "unexpected data type")
assert.Equal(t, p, p2, "unexpected payload")
}

func assertSubprotocol(t *testing.T, c *websocket.Conn, exp string) {
t.Helper()

assert.Equalf(t, exp, c.Subprotocol(), "unexpected subprotocol")
assert.Equal(t, exp, c.Subprotocol(), "unexpected subprotocol")
}

func assertCloseStatus(t *testing.T, exp websocket.StatusCode, err error) {
t.Helper()

assert.Equalf(t, exp, websocket.CloseStatus(err), "unexpected status code")
assert.Equal(t, exp, websocket.CloseStatus(err), "unexpected status code")
}
4 changes: 1 addition & 3 deletionsci/test.mk
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,4 @@ coveralls: gotest
gotest:
go test -covermode=count -coverprofile=ci/out/coverage.prof -coverpkg=./... $${GOTESTFLAGS-} ./...
sed -i '/_stringer\.go/d' ci/out/coverage.prof
sed -i '/wsecho\.go/d' ci/out/coverage.prof
sed -i '/assert\.go/d' ci/out/coverage.prof
sed -i '/wsgrace\.go/d' ci/out/coverage.prof
sed -i '/assert/d' ci/out/coverage.prof
6 changes: 3 additions & 3 deletionsclose.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import (
"errors"
"fmt"
"log"
"nhooyr.io/websocket/internal/bufpool"
"nhooyr.io/websocket/internal/bpool"
"time"
)

Expand DownExpand Up@@ -146,10 +146,10 @@ func (cr *connReader) waitClose() error {
}
defer cr.mu.Unlock()

b :=bufpool.Get()
b :=bpool.Get()
buf := b.Bytes()
buf = buf[:cap(buf)]
deferbufpool.Put(b)
deferbpool.Put(b)

for {
// TODO
Expand Down
2 changes: 1 addition & 1 deletionclose_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ func TestCloseStatus(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

assert.Equalf(t, tc.exp, CloseStatus(tc.in), "unexpected close status")
assert.Equal(t, tc.exp, CloseStatus(tc.in), "unexpected close status")
})
}
}
1 change: 0 additions & 1 deletionframe.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import (
"encoding/binary"
"math"
"math/bits"
"nhooyr.io/websocket/internal/errd"
)

// opcode represents a WebSocket opcode.
Expand Down
6 changes: 3 additions & 3 deletionsframe_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90,7 +90,7 @@ func testHeader(t *testing.T, h header) {
h2, err := readFrameHeader(r)
assert.Success(t, err)

assert.Equalf(t, h, h2, "written and read headers differ")
assert.Equal(t, h, h2, "written and read headers differ")
}

func Test_mask(t *testing.T) {
Expand All@@ -101,8 +101,8 @@ func Test_mask(t *testing.T) {
p := []byte{0xa, 0xb, 0xc, 0xf2, 0xc}
gotKey32 := mask(key32, p)

assert.Equalf(t, []byte{0, 0, 0, 0x0d, 0x6}, p, "unexpected mask")
assert.Equalf(t, bits.RotateLeft32(key32, -8), gotKey32, "unexpected mask key")
assert.Equal(t, []byte{0, 0, 0, 0x0d, 0x6}, p, "unexpected mask")
assert.Equal(t, bits.RotateLeft32(key32, -8), gotKey32, "unexpected mask key")
}

func basicMask(maskKey [4]byte, pos int, b []byte) int {
Expand Down
4 changes: 2 additions & 2 deletionsgo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,13 +7,13 @@ require (
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee // indirect
github.com/gobwas/pool v0.2.0 // indirect
github.com/gobwas/ws v1.0.2
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.3.1
github.com/gorilla/websocket v1.4.1
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.4.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)
69 changes: 6 additions & 63 deletionsinternal/assert/assert.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,29 @@
package assert

import (
"reflect"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
)

// https://github.com/google/go-cmp/issues/40#issuecomment-328615283
func cmpDiff(exp, act interface{}) string {
return cmp.Diff(exp, act, deepAllowUnexported(exp, act))
}

func deepAllowUnexported(vs ...interface{}) cmp.Option {
m := make(map[reflect.Type]struct{})
for _, v := range vs {
structTypes(reflect.ValueOf(v), m)
}
var typs []interface{}
for t := range m {
typs = append(typs, reflect.New(t).Elem().Interface())
}
return cmp.AllowUnexported(typs...)
}

func structTypes(v reflect.Value, m map[reflect.Type]struct{}) {
if !v.IsValid() {
return
}
switch v.Kind() {
case reflect.Ptr:
if !v.IsNil() {
structTypes(v.Elem(), m)
}
case reflect.Interface:
if !v.IsNil() {
structTypes(v.Elem(), m)
}
case reflect.Slice, reflect.Array:
for i := 0; i < v.Len(); i++ {
structTypes(v.Index(i), m)
}
case reflect.Map:
for _, k := range v.MapKeys() {
structTypes(v.MapIndex(k), m)
}
case reflect.Struct:
m[v.Type()] = struct{}{}
for i := 0; i < v.NumField(); i++ {
structTypes(v.Field(i), m)
}
}
}

func Equalf(t testing.TB, exp, act interface{}, f string, v ...interface{}) {
func Equal(t testing.TB, exp, act interface{}, name string) {
t.Helper()
diff := cmpDiff(exp, act)
if diff != "" {
t.Fatalf(f+": %v",append(v, diff)...)
t.Fatalf("unexpected %v: %v",name, diff)
}
}

funcNotEqualf(t testing.TB, exp, act interface{},f string, v ...interface{}) {
funcNotEqual(t testing.TB, exp, act interface{},name string) {
t.Helper()
diff := cmpDiff(exp, act)
if diff == "" {
t.Fatalf(f+": %v", append(v, diff)...)
if cmpDiff(exp, act) == "" {
t.Fatalf("expected different %v: %+v", name, act)
}
}

func Success(t testing.TB, err error) {
t.Helper()
if err != nil {
t.Fatalf("unexpected error: %+v", err)
t.Fatalf("unexpected error: %+v", err)
}
}

Expand All@@ -92,10 +42,3 @@ func ErrorContains(t testing.TB, err error, sub string) {
t.Fatalf("error string %q does not contain %q", errs, sub)
}
}

func Panicf(t testing.TB, f string, v ...interface{}) {
r := recover()
if r == nil {
t.Fatalf(f, v...)
}
}
52 changes: 52 additions & 0 deletionsinternal/assert/cmp.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
package assert

import (
"github.com/google/go-cmp/cmp"
"reflect"
)

// https://github.com/google/go-cmp/issues/40#issuecomment-328615283
func cmpDiff(exp, act interface{}) string {
return cmp.Diff(exp, act, deepAllowUnexported(exp, act))
}

func deepAllowUnexported(vs ...interface{}) cmp.Option {
m := make(map[reflect.Type]struct{})
for _, v := range vs {
structTypes(reflect.ValueOf(v), m)
}
var typs []interface{}
for t := range m {
typs = append(typs, reflect.New(t).Elem().Interface())
}
return cmp.AllowUnexported(typs...)
}

func structTypes(v reflect.Value, m map[reflect.Type]struct{}) {
if !v.IsValid() {
return
}
switch v.Kind() {
case reflect.Ptr:
if !v.IsNil() {
structTypes(v.Elem(), m)
}
case reflect.Interface:
if !v.IsNil() {
structTypes(v.Elem(), m)
}
case reflect.Slice, reflect.Array:
for i := 0; i < v.Len(); i++ {
structTypes(v.Index(i), m)
}
case reflect.Map:
for _, k := range v.MapKeys() {
structTypes(v.MapIndex(k), m)
}
case reflect.Struct:
m[v.Type()] = struct{}{}
for i := 0; i < v.NumField(); i++ {
structTypes(v.Field(i), m)
}
}
}
10 changes: 5 additions & 5 deletionsinternal/bufpool/buf.go → internal/bpool/bpool.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
packagebufpool
packagebpool

import (
"bytes"
Expand All@@ -10,11 +10,11 @@ var pool sync.Pool
// Get returns a buffer from the pool or creates a new one if
// the pool is empty.
func Get() *bytes.Buffer {
b, ok:= pool.Get().(*bytes.Buffer)
if!ok {
b = &bytes.Buffer{}
b:= pool.Get()
ifb == nil {
return &bytes.Buffer{}
}
return b
return b.(*bytes.Buffer)
}

// Put returns a buffer into the pool.
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp