diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml index 0aba7465a..89e2bcf8a 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -92,8 +92,8 @@ body: - type: textarea id: code attributes: - label: Code snippets (optional) - description: Helpful code snippets can really speed up the process of locating root cause and fixing the bug. + label: Reproducer + description: Please provide the minimal code to reproduce the bug. render: go - type: textarea id: how-to-reproduce diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 404814091..6f1a91b48 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -43,7 +43,7 @@ autolabeler: title: - /fix/i - /bug/i - - /patch/i + - /resolve/i - label: docs files: - '*.md' @@ -59,6 +59,15 @@ autolabeler: - /update/i - /remove/i - /delete/i + - label: optimization + title: + - /opt:/i + - /refactor/i + - /optimize/i + - /improve/i + - /update/i + - /remove/i + - /delete/i - label: new feature title: - /feat:/i @@ -75,7 +84,7 @@ autolabeler: - label: chores title: - /chore/i - - /\bmisc\b/i + - /misc/i - /cleanup/i - /clean up/i - label: major diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 36e3b5ea5..5f1474644 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -32,7 +32,7 @@ jobs: # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml # with: # config-name: my-config.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e964a415..3cb3e46ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,7 +94,7 @@ jobs: run: go test -v -race -coverprofile="codecov.report" -covermode=atomic -timeout 15m -failfast - name: Upload the code coverage report to codecov.io - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: files: ./codecov.report flags: unittests diff --git a/.github/workflows/test_gc_opt.yml b/.github/workflows/test_gc_opt.yml index df99ae8e2..2660f976d 100644 --- a/.github/workflows/test_gc_opt.yml +++ b/.github/workflows/test_gc_opt.yml @@ -94,7 +94,7 @@ jobs: run: go test -v -race -tags=gc_opt -coverprofile="codecov.report" -covermode=atomic -timeout 15m -failfast - name: Upload the code coverage report to codecov.io - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: files: ./codecov.report flags: unittests diff --git a/.github/workflows/test_poll_opt.yml b/.github/workflows/test_poll_opt.yml index 5d5ae19fc..48898fe91 100644 --- a/.github/workflows/test_poll_opt.yml +++ b/.github/workflows/test_poll_opt.yml @@ -90,7 +90,7 @@ jobs: run: go test -v -tags=poll_opt -coverprofile="codecov.report" -covermode=atomic -timeout 10m -failfast - name: Upload the code coverage report to codecov.io - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: files: ./codecov.report flags: unittests diff --git a/.github/workflows/test_poll_opt_gc_opt.yml b/.github/workflows/test_poll_opt_gc_opt.yml index a5aef4062..61c6ab461 100644 --- a/.github/workflows/test_poll_opt_gc_opt.yml +++ b/.github/workflows/test_poll_opt_gc_opt.yml @@ -90,7 +90,7 @@ jobs: run: go test -v -tags=poll_opt,gc_opt -coverprofile="codecov.report" -covermode=atomic -timeout 10m -failfast - name: Upload the code coverage report to codecov.io - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: files: ./codecov.report flags: unittests diff --git a/README.md b/README.md index e4969d391..8f1280b9f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@

+

+panjf2000%2Fgnet | Trendshift +

+ English | [δΈ­ζ–‡](README_ZH.md) ### πŸŽ‰πŸŽ‰πŸŽ‰ Feel free to join [the channels about `gnet` on the Discord Server](https://discord.gg/UyKD7NZcfH). @@ -120,6 +124,13 @@ The following corporations/organizations use `gnet` as the underlying network se + + + + + + + diff --git a/README_ZH.md b/README_ZH.md index e40c6749e..e8a122b25 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -13,6 +13,10 @@

+

+panjf2000%2Fgnet | Trendshift +

+ [θ‹±ζ–‡](README.md) | δΈ­ζ–‡ ### πŸŽ‰πŸŽ‰πŸŽ‰ 欒迎加ε…₯ `gnet` 在 [Discord ζœεŠ‘ε™¨δΈŠηš„ι’‘ι“](https://discord.gg/UyKD7NZcfH). @@ -120,6 +124,13 @@ go get -u github.com/panjf2000/gnet + + + + + + + diff --git a/connection_windows.go b/connection_windows.go index fe8ccb187..e40136e2e 100644 --- a/connection_windows.go +++ b/connection_windows.go @@ -421,21 +421,21 @@ var workerPool = nonBlockingPool{Pool: goPool.Default()} // func (c *conn) Gfd() gfd.GFD { return gfd.GFD{} } func (c *conn) AsyncWrite(buf []byte, cb AsyncCallback) error { - _, err := c.Write(buf) - - callback := func() error { + fn := func() error { + _, err := c.Write(buf) if cb != nil { _ = cb(c, err) } return err } + var err error select { - case c.loop.ch <- callback: + case c.loop.ch <- fn: default: // If the event-loop channel is full, asynchronize this operation to avoid blocking the eventloop. err = workerPool.Go(func() { - c.loop.ch <- callback + c.loop.ch <- fn }) } diff --git a/gnet_test.go b/gnet_test.go index b6755e038..2b02a08b6 100644 --- a/gnet_test.go +++ b/gnet_test.go @@ -1532,6 +1532,89 @@ func TestMultiInstLoggerRace(t *testing.T) { assert.ErrorIs(t, g.Wait(), errorx.ErrUnsupportedProtocol) } +type testDisconnectedAsyncWriteServer struct { + BuiltinEventEngine + tester *testing.T + addr string + writev, clientStarted bool + exit atomic.Bool +} + +func (t *testDisconnectedAsyncWriteServer) OnTraffic(c Conn) Action { + _, err := c.Next(0) + require.NoErrorf(t.tester, err, "c.Next error: %v", err) + + go func() { + for range time.Tick(100 * time.Millisecond) { + if t.exit.Load() { + break + } + + if t.writev { + err = c.AsyncWritev([][]byte{[]byte("hello"), []byte("hello")}, func(_ Conn, err error) error { + if err == nil { + return nil + } + + require.ErrorIsf(t.tester, err, net.ErrClosed, "expected error: %v, but got: %v", net.ErrClosed, err) + t.exit.Store(true) + return nil + }) + } else { + err = c.AsyncWrite([]byte("hello"), func(_ Conn, err error) error { + if err == nil { + return nil + } + + require.ErrorIsf(t.tester, err, net.ErrClosed, "expected error: %v, but got: %v", net.ErrClosed, err) + t.exit.Store(true) + return nil + }) + } + + if err != nil { + return + } + } + }() + + return None +} + +func (t *testDisconnectedAsyncWriteServer) OnTick() (delay time.Duration, action Action) { + delay = 500 * time.Millisecond + + if t.exit.Load() { + action = Shutdown + return + } + + if !t.clientStarted { + t.clientStarted = true + go func() { + c, err := net.Dial("tcp", t.addr) + require.NoError(t.tester, err) + _, err = c.Write([]byte("hello")) + require.NoError(t.tester, err) + require.NoError(t.tester, c.Close()) + }() + } + return +} + +func TestDisconnectedAsyncWrite(t *testing.T) { + t.Run("async-write", func(t *testing.T) { + events := &testDisconnectedAsyncWriteServer{tester: t, addr: ":10000"} + err := Run(events, "tcp://:10000", WithTicker(true)) + assert.NoError(t, err) + }) + t.Run("async-writev", func(t *testing.T) { + events := &testDisconnectedAsyncWriteServer{tester: t, addr: ":10001", writev: true} + err := Run(events, "tcp://:10001", WithTicker(true)) + assert.NoError(t, err) + }) +} + var errIncompletePacket = errors.New("incomplete packet") type simServer struct { diff --git a/go.mod b/go.mod index 0ab63f761..44567ae7f 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,19 @@ module github.com/panjf2000/gnet/v2 require ( - github.com/panjf2000/ants/v2 v2.10.0 - github.com/stretchr/testify v1.9.0 + github.com/panjf2000/ants/v2 v2.11.0 + github.com/stretchr/testify v1.10.0 github.com/valyala/bytebufferpool v1.0.0 - go.uber.org/zap v1.21.0 // don't upgrade this one - golang.org/x/sync v0.8.0 - golang.org/x/sys v0.25.0 + go.uber.org/zap v1.27.0 + golang.org/x/sync v0.11.0 + golang.org/x/sys v0.30.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect + go.uber.org/multierr v1.11.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 6c36aa9be..d13d02571 100644 --- a/go.sum +++ b/go.sum @@ -1,78 +1,25 @@ -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/panjf2000/ants/v2 v2.10.0 h1:zhRg1pQUtkyRiOFo2Sbqwjp0GfBNo9cUY2/Grpx1p+8= -github.com/panjf2000/ants/v2 v2.10.0/go.mod h1:7ZxyxsqE4vvW0M7LSD8aI3cKwgFhBHbxnlN8mDqHa1I= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/panjf2000/ants/v2 v2.11.0 h1:sHrqEwTBQTQ2w6PMvbMfvBtVUuhsaYPzUmAYDLYmJPg= +github.com/panjf2000/ants/v2 v2.11.0/go.mod h1:V9HhTupTWxcaRmIglJvGwvzqXUTnIZW9uO6q4hAfApw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/os_unix_test.go b/os_unix_test.go index 1b100f9b4..73dcb832f 100644 --- a/os_unix_test.go +++ b/os_unix_test.go @@ -126,7 +126,7 @@ func (s *testMcastServer) startMcastClient() { require.NoError(s.t, err) // Workaround for MacOS "write: no buffer space available" error messages // https://developer.apple.com/forums/thread/42334 - time.Sleep(time.Millisecond) + time.Sleep(time.Millisecond * 100) select { case respData := <-ch: require.Equalf(s.t, reqData, respData, "response mismatch, length of bytes: %d vs %d", len(reqData), len(respData)) diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index 5ccc3e7da..ea3a96c27 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package logging provides logging functionality for gnet server, +// Package logging provides logging functionality for gnet applications, // it sets up a default logger (powered by go.uber.org/zap) -// which is about to be used by gnet server, it also allows users -// to replace the default logger with their customized logger by just -// implementing the `Logger` interface and assign it to the functional option `Options.Logger`, -// pass it to `gnet.Serve` method. +// that is about to be used by your gnet application. +// You're allowed to replace the default logger with your customized logger by +// implementing Logger and assign it to the functional option via gnet.WithLogger, +// and then passing it to gnet.Run or gnet.Rotate. // // The environment variable `GNET_LOGGING_LEVEL` determines which zap logger level will be applied for logging. // The environment variable `GNET_LOGGING_FILE` is set to a local file path when you want to print logs into local file. diff --git a/pkg/pool/goroutine/goroutine.go b/pkg/pool/goroutine/goroutine.go index eb27f45e3..9c641c5e3 100644 --- a/pkg/pool/goroutine/goroutine.go +++ b/pkg/pool/goroutine/goroutine.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package goroutine is a wrapper of ants. +// Package goroutine is a wrapper of github.com/panjf2000/ants with some practical configurations. package goroutine import ( @@ -52,7 +52,7 @@ func (l antsLogger) Printf(format string, args ...any) { l.Infof(format, args...) } -// Default instantiates a non-blocking *WorkerPool with the capacity of DefaultAntsPoolSize. +// Default instantiates a non-blocking goroutine pool with the capacity of DefaultAntsPoolSize. func Default() *Pool { options := ants.Options{ ExpiryDuration: ExpiryDuration,