Skip to content

ejunjsh/nettyG

Repository files navigation

nettyG

Build Status

a simple netty-like network framework.

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

$ 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

About

a netty-like framework with go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages