https://github.com/ejunjsh/nettyg
a netty-like framework with go
https://github.com/ejunjsh/nettyg
Last synced: 29 days ago
JSON representation
a netty-like framework with go
- Host: GitHub
- URL: https://github.com/ejunjsh/nettyg
- Owner: ejunjsh
- Created: 2017-07-25T12:30:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T03:03:21.000Z (over 7 years ago)
- Last Synced: 2025-03-27T00:54:55.133Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 14
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nettyG
[](https://travis-ci.org/ejunjsh/nettyG)a simple netty-like network framework.
````go
NewBootstrap().Handler(func(channel *Channel) {
channel.Pipeline().
AddLast(NewLineCodec("\r\n\r\n")).
AddLast(NewStringCodec()).
AddLast(ChannelActiveFunc(func(context *HandlerContext) error {
context.WriteAndFlush("hello nettyG")
return nil
})).AddLast(ChannelReadFunc(func(context *HandlerContext, data interface{}) error {
if d,ok:=data.(string);ok{
context.Write(d)
}
return nil
}))
}).RunServer("tcp",":8981")
````benchmark
nettyG vs go standard lib
````bash
$ cd bench
$ go test -bench .
tcp listen on :8981
BenchmarkGostd-8 10000 123746 ns/op
BenchmarkNettyG-8 10000 134753 ns/op
PASS
ok github.com/ejunjsh/nettyG 2.623s````