Skip to content

Commit a7e541b

Browse files
authored
Merge pull request #668 from panjf2000/dev
minor: v2.7.0
2 parents c1270b4 + 1de2082 commit a7e541b

File tree

78 files changed

+290
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+290
-104
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ English | [中文](README_ZH.md)
2121

2222
`gnet` is an event-driven networking framework that is ultra-fast and lightweight. It is built from scratch by exploiting [epoll](https://man7.org/linux/man-pages/man7/epoll.7.html) and [kqueue](https://en.wikipedia.org/wiki/Kqueue) and it can achieve much higher performance with lower memory consumption than Go [net](https://golang.org/pkg/net/) in many specific scenarios.
2323

24-
`gnet` and [net](https://golang.org/pkg/net/) don't share the same philosophy about network programming. Thus, building network applications with `gnet` can be significantly different from building them with [net](https://golang.org/pkg/net/), and the philosophies can't be reconciled. There are other similar products written in other programming languages in the community, such as [libuv](https://github.com/libuv/libuv), [netty](https://github.com/netty/netty), [twisted](https://github.com/twisted/twisted), [tornado](https://github.com/tornadoweb/tornado), etc. which work in a similar pattern as `gnet` under the hood.
24+
`gnet` and [net](https://golang.org/pkg/net/) don't share the same philosophy in network programming. Thus, building network applications with `gnet` can be significantly different from building them with [net](https://golang.org/pkg/net/), and the philosophies can't be reconciled. There are other similar products written in other programming languages in the community, such as [libuv](https://github.com/libuv/libuv), [netty](https://github.com/netty/netty), [twisted](https://github.com/twisted/twisted), [tornado](https://github.com/tornadoweb/tornado), etc. which work in a similar pattern as `gnet` under the hood.
2525

2626
`gnet` is not designed to displace the Go [net](https://golang.org/pkg/net/), but to create an alternative in the Go ecosystem for building performance-critical network services. As a result of which, `gnet` is not as comprehensive as Go [net](https://golang.org/pkg/net/), it provides only the core functionality (via a concise set of APIs) required by a network application and it doesn't plan on becoming a coverall networking framework, as I think Go [net](https://golang.org/pkg/net/) has done a good enough job in that area.
2727

README_ZH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
`gnet` 是一个基于事件驱动的高性能和轻量级网络框架。这个框架是基于 [epoll](https://en.wikipedia.org/wiki/Epoll)[kqueue](https://en.wikipedia.org/wiki/Kqueue) 从零开发的,而且相比 Go [net](https://golang.org/pkg/net/),它能以更低的内存占用实现更高的性能。
2323

24-
`gnet`[net](https://golang.org/pkg/net/) 有着不一样的网络编程模式。因此,用 `gnet` 开发网络应用和用 [net](https://golang.org/pkg/net/) 开发区别很大,而且两者之间不可调和。社区里有其他同类的产品像是 [libuv](https://github.com/libuv/libuv), [netty](https://github.com/netty/netty), [twisted](https://github.com/twisted/twisted), [tornado](https://github.com/tornadoweb/tornado)`gnet` 的底层工作原理和这些框架非常类似。
24+
`gnet`[net](https://golang.org/pkg/net/) 有着不一样的网络编程范式。因此,用 `gnet` 开发网络应用和用 [net](https://golang.org/pkg/net/) 开发区别很大,而且两者之间不可调和。社区里有其他同类的产品像是 [libuv](https://github.com/libuv/libuv), [netty](https://github.com/netty/netty), [twisted](https://github.com/twisted/twisted), [tornado](https://github.com/tornadoweb/tornado)`gnet` 的底层工作原理和这些框架非常类似。
2525

2626
`gnet` 不是为了取代 [net](https://golang.org/pkg/net/) 而生的,而是在 Go 生态中为开发者提供一个开发性能敏感的网络服务的替代品。也正因如此,`gnet` 在功能全面性上比不了 Go [net](https://golang.org/pkg/net/),它只会提供网络应用所需的最核心的功能和最精简的 APIs,而且 `gnet` 也并没有打算变成一个无所不包的网络框架,因为我觉得 Go [net](https://golang.org/pkg/net/) 在这方面已经做得足够好了。
2727

acceptor_unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import (
2222

2323
"golang.org/x/sys/unix"
2424

25-
"github.com/panjf2000/gnet/v2/internal/netpoll"
26-
"github.com/panjf2000/gnet/v2/internal/queue"
27-
"github.com/panjf2000/gnet/v2/internal/socket"
2825
"github.com/panjf2000/gnet/v2/pkg/errors"
26+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
27+
"github.com/panjf2000/gnet/v2/pkg/queue"
28+
"github.com/panjf2000/gnet/v2/pkg/socket"
2929
)
3030

3131
func (el *eventloop) accept0(fd int, _ netpoll.IOEvent, _ netpoll.IOFlags) error {

client_unix.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import (
2727
"golang.org/x/sync/errgroup"
2828
"golang.org/x/sys/unix"
2929

30-
"github.com/panjf2000/gnet/v2/internal/math"
31-
"github.com/panjf2000/gnet/v2/internal/netpoll"
32-
"github.com/panjf2000/gnet/v2/internal/queue"
33-
"github.com/panjf2000/gnet/v2/internal/socket"
3430
"github.com/panjf2000/gnet/v2/pkg/buffer/ring"
3531
errorx "github.com/panjf2000/gnet/v2/pkg/errors"
3632
"github.com/panjf2000/gnet/v2/pkg/logging"
33+
"github.com/panjf2000/gnet/v2/pkg/math"
34+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
35+
"github.com/panjf2000/gnet/v2/pkg/queue"
36+
"github.com/panjf2000/gnet/v2/pkg/socket"
3737
)
3838

3939
// Client of gnet.

connection_bsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"golang.org/x/sys/unix"
2424

25-
"github.com/panjf2000/gnet/v2/internal/netpoll"
25+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
2626
)
2727

2828
func (c *conn) processIO(_ int, filter netpoll.IOEvent, flags netpoll.IOFlags) (err error) {

connection_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"golang.org/x/sys/unix"
2424

25-
"github.com/panjf2000/gnet/v2/internal/netpoll"
25+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
2626
)
2727

2828
func (c *conn) processIO(_ int, ev netpoll.IOEvent, _ netpoll.IOFlags) error {

connection_unix.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ import (
2525

2626
"golang.org/x/sys/unix"
2727

28-
"github.com/panjf2000/gnet/v2/internal/bs"
2928
"github.com/panjf2000/gnet/v2/internal/gfd"
30-
gio "github.com/panjf2000/gnet/v2/internal/io"
31-
"github.com/panjf2000/gnet/v2/internal/netpoll"
32-
"github.com/panjf2000/gnet/v2/internal/queue"
33-
"github.com/panjf2000/gnet/v2/internal/socket"
29+
"github.com/panjf2000/gnet/v2/pkg/bs"
3430
"github.com/panjf2000/gnet/v2/pkg/buffer/elastic"
3531
errorx "github.com/panjf2000/gnet/v2/pkg/errors"
32+
gio "github.com/panjf2000/gnet/v2/pkg/io"
3633
"github.com/panjf2000/gnet/v2/pkg/logging"
34+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
3735
bsPool "github.com/panjf2000/gnet/v2/pkg/pool/byteslice"
36+
"github.com/panjf2000/gnet/v2/pkg/queue"
37+
"github.com/panjf2000/gnet/v2/pkg/socket"
3838
)
3939

4040
type conn struct {

engine_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
"golang.org/x/sync/errgroup"
2828

2929
"github.com/panjf2000/gnet/v2/internal/gfd"
30-
"github.com/panjf2000/gnet/v2/internal/netpoll"
31-
"github.com/panjf2000/gnet/v2/internal/queue"
3230
errorx "github.com/panjf2000/gnet/v2/pkg/errors"
3331
"github.com/panjf2000/gnet/v2/pkg/logging"
32+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
33+
"github.com/panjf2000/gnet/v2/pkg/queue"
3434
)
3535

3636
type engine struct {

eventloop_unix.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import (
2828

2929
"golang.org/x/sys/unix"
3030

31-
gio "github.com/panjf2000/gnet/v2/internal/io"
32-
"github.com/panjf2000/gnet/v2/internal/netpoll"
33-
"github.com/panjf2000/gnet/v2/internal/queue"
3431
errorx "github.com/panjf2000/gnet/v2/pkg/errors"
32+
gio "github.com/panjf2000/gnet/v2/pkg/io"
3533
"github.com/panjf2000/gnet/v2/pkg/logging"
34+
"github.com/panjf2000/gnet/v2/pkg/netpoll"
35+
"github.com/panjf2000/gnet/v2/pkg/queue"
3636
)
3737

3838
type eventloop struct {
@@ -238,11 +238,11 @@ func (el *eventloop) close(c *conn, err error) error {
238238
if len(iov) > iovMax {
239239
iov = iov[:iovMax]
240240
}
241-
if n, e := gio.Writev(c.fd, iov); e != nil {
241+
n, err := gio.Writev(c.fd, iov)
242+
if err != nil {
242243
break
243-
} else { //nolint:revive
244-
_, _ = c.outboundBuffer.Discard(n)
245244
}
245+
_, _ = c.outboundBuffer.Discard(n)
246246
}
247247

248248
c.release()

gnet.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Package gnet implements a high-performance, lightweight, non-blocking,
16+
// event-driven networking framework written in pure Go.
17+
//
18+
// Visit https://gnet.host/ for more details about gnet.
1519
package gnet
1620

1721
import (
@@ -23,10 +27,10 @@ import (
2327
"sync"
2428
"time"
2529

26-
"github.com/panjf2000/gnet/v2/internal/math"
2730
"github.com/panjf2000/gnet/v2/pkg/buffer/ring"
2831
"github.com/panjf2000/gnet/v2/pkg/errors"
2932
"github.com/panjf2000/gnet/v2/pkg/logging"
33+
"github.com/panjf2000/gnet/v2/pkg/math"
3034
)
3135

3236
// Action is an action that occurs after the completion of an event.

0 commit comments

Comments
 (0)