Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ejunjsh/nettyg
a netty-like framework with go
https://github.com/ejunjsh/nettyg
Last synced: about 5 hours 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T03:03:21.000Z (about 7 years ago)
- Last Synced: 2023-03-05T02:28:17.659Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 13
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nettyG
[![Build Status](https://travis-ci.org/ejunjsh/nettyG.svg?branch=master)](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````