Commit b11bcf8e authored by alexstocks's avatar alexstocks

add test examples

parent 81c7e8fe
...@@ -50,6 +50,8 @@ type ( ...@@ -50,6 +50,8 @@ type (
// Config holds supported types by the multiconfig package // Config holds supported types by the multiconfig package
Config struct { Config struct {
// local
AppName string `default:"echo-client"`
LocalHost string `default:"127.0.0.1"` LocalHost string `default:"127.0.0.1"`
// server // server
......
...@@ -47,6 +47,8 @@ func main() { ...@@ -47,6 +47,8 @@ func main() {
initProfiling() initProfiling()
initClient() initClient()
gocolor.Info("%s starts successfull! its version=%s\n", conf.AppName, Version)
log.Info("%s starts successfull! its version=%s\n", conf.AppName, Version)
go test() go test()
...@@ -168,5 +170,6 @@ func test() { ...@@ -168,5 +170,6 @@ func test() {
echo() echo()
} }
cost = counter.Count() cost = counter.Count()
log.Info("after loop %d times, echo cost %d ms", conf.EchoTimes, cost/1e6)
gocolor.Info("after loop %d times, echo cost %d ms", conf.EchoTimes, cost/1e6) gocolor.Info("after loop %d times, echo cost %d ms", conf.EchoTimes, cost/1e6)
} }
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
package main package main
var ( var (
Version = "0.3.04" Version = "0.3.07"
) )
# toml configure file # toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写 # toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
AppName = "ECHO-CLIENT"
# host # host
LocalHost = "127.0.0.1" LocalHost = "127.0.0.1"
...@@ -25,7 +27,7 @@ SessionTimeout = "20s" ...@@ -25,7 +27,7 @@ SessionTimeout = "20s"
# client echo request string # client echo request string
EchoString = "Hello, getty!" EchoString = "Hello, getty!"
# 发送echo请求次数 # 发送echo请求次数
EchoTimes = 100000 EchoTimes = 10000
# app fail fast # app fail fast
FailFastTimeout = "3s" FailFastTimeout = "3s"
......
...@@ -51,6 +51,7 @@ type ( ...@@ -51,6 +51,7 @@ type (
// Config holds supported types by the multiconfig package // Config holds supported types by the multiconfig package
Config struct { Config struct {
// local address // local address
AppName string `default:"echo-server"`
Host string `default:"127.0.0.1"` Host string `default:"127.0.0.1"`
Ports []string `default:["10000"]` Ports []string `default:["10000"]`
ProfilePort int `default:"10086"` ProfilePort int `default:"10086"`
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
import ( import (
"github.com/AlexStocks/getty" "github.com/AlexStocks/getty"
"github.com/AlexStocks/gocolor"
log "github.com/AlexStocks/log4go" log "github.com/AlexStocks/log4go"
) )
...@@ -51,6 +52,10 @@ func main() { ...@@ -51,6 +52,10 @@ func main() {
initProfiling() initProfiling()
initServer() initServer()
gocolor.Info("%s starts successfull! its version=%s, its listen ends=%s:%s\n",
conf.AppName, Version, conf.Host, conf.Ports)
log.Info("%s starts successfull! its version=%s, its listen ends=%s:%s\n",
conf.AppName, Version, conf.Host, conf.Ports)
initSignal() initSignal()
} }
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
package main package main
var ( var (
Version = "0.3.04" Version = "0.3.07"
) )
# toml configure file # toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写 # toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
AppName = "ECHO-SERVER"
# Host = "127.0.0.1" # Host = "127.0.0.1"
Host = "192.168.35.1" Host = "192.168.35.1"
Ports = ["10000", "20000"] Ports = ["10000", "20000"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment