在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:tidwall/evio开源软件地址:https://github.com/tidwall/evio开源编程语言:Go 95.1%开源软件介绍:
The goal of this project is to create a server framework for Go that performs on par with Redis and Haproxy for packet handling. It was built to be the foundation for Tile38 and a future L7 proxy for Go. Please note: Evio should not be considered as a drop-in replacement for the standard Go net or net/http packages. Features
Getting StartedInstallingTo start using evio, install Go and run $ go get -u github.com/tidwall/evio This will retrieve the library. UsageStarting a server is easy with Example echo server that binds to port 5000: package main
import "github.com/tidwall/evio"
func main() {
var events evio.Events
events.Data = func(c evio.Conn, in []byte) (out []byte, action evio.Action) {
out = in
return
}
if err := evio.Serve(events, "tcp://localhost:5000"); err != nil {
panic(err.Error())
}
} Here the only event being used is Connect to the echo server: $ telnet localhost 5000 EventsThe event type has a bunch of handy events:
Multiple addressesA server can bind to multiple addresses and share the same event loop. evio.Serve(events, "tcp://192.168.0.10:5000", "unix://socket") TickerThe events.Tick = func() (delay time.Duration, action Action){
log.Printf("tick")
delay = time.Second
return
} UDPThe
MultithreadedThe Load balancingThe
SO_REUSEPORTServers can utilize the SO_REUSEPORT option which allows multiple sockets on the same host to bind to the same port. Just provide evio.Serve(events, "tcp://0.0.0.0:1234?reuseport=true")) More examplesPlease check out the examples subdirectory for a simplified redis clone, an echo server, and a very basic http server. To run an example: $ go run examples/http-server/main.go
$ go run examples/redis-server/main.go
$ go run examples/echo-server/main.go PerformanceBenchmarksThese benchmarks were run on an ec2 c4.xlarge instance in single-threaded mode (GOMAXPROC=1) over Ipv4 localhost. Check out benchmarks for more info. ContactJosh Baker @tidwall License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论