README ¶ core core for go services tcp epoll server import ( "fmt" "io" "github.com/deweppro/core/pkg/server" tcpepoll "github.com/deweppro/core/pkg/server/tcp-epoll" "github.com/deweppro/go-app/pkg/app" ) func main() { app.New("config.yaml").Modules(newtest).Run() } type test struct { s *tcpepoll.Server } func newtest() *test { return &test{ s: tcpepoll.New(), } } func (t *test) Up() error { addr, err := server.RandomPort("0.0.0.0") if err != nil { return err } t.s.SetAddr(addr) t.s.SetHandler(t.handler) return t.s.Up() } func (t *test) Down() error { return t.s.Down() } func (t *test) handler(r []byte, w io.Writer) error { fmt.Println(string(r)) if _, err := w.Write([]byte("Bye bye!")); err != nil { // close connection for all errors with write to log return err } return io.EOF } Expand ▾ Collapse ▴ Directories ¶ Show internal Expand all Path Synopsis pkg auth/jwt db/leveldb db/mysql db/nats db/redis db/sqlite debug filesystem/git filesystem/shell filesystem/ssh server server/http server/tcp-epoll server/websocket Click to show internal directories. Click to hide internal directories.