func main() { runtime.GOMAXPROCS(common.MaxCPU) println("cpu num is ", common.MaxCPU) cfg, err := config.Read("config.xml") if err != nil { panic(err.Error()) } rcfg, err := config.ReadRelation("relation.xml") if err != nil { panic(err.Error()) } cache.Init(cfg, rcfg) LoadBaseData() dispatcher.Start(cfg) time.Sleep(time.Hour) //if str, err := ioutil.ReadFile("config/config.xml"); err == nil { // ioutil.WriteFile("config.xml", str, os.ModePerm) //} else { // panic(err.Error()) //}// //test.Test_Dispatcher() //test.Test_MutiCache() //test.Test_Push() //test.Test_WebSocket() a, err := time.Parse(common.TimeFormat, "2014-02-12 12:59") b, err := time.Parse(common.TimeFormat, "2014-02-12 13:00") println(a.Before(b), err) println(a.After(b)) println(a.Sub(b)) println(a.String()) println(b.String()) }
func Test_TestInput(t *testing.T) { c, err := config.Read("../../config.xml") if err != nil { t.Error(err.Error()) } for _, cfg := range c.Inputs.CsvInputs { test := New(cfg) common.IsRun = true test.Config.FileName = "../../test.csv" test.Start() for o := range test.Output { println(o.Time) } } }
func Test_TestInput(t *testing.T) { c, err := config.Read("../../config.xml") if err != nil { t.Error(err.Error()) } for _, cfg := range c.Inputs.TestInputs { test := New(cfg) go func() { for out := range test.Output { t.Log(out) } }() test.Start() time.Sleep(time.Second) } }
func Test_Redis(t *testing.T) { cfg, err := config.Read("../config.xml") if err != nil { t.Fatal(err.Error()) } Init(cfg, nil) if c, err := GetClient("d"); err != nil { t.Error(err.Error()) } else { RedisStatus() if result, err := c.Redis.AllKeys(); err == nil { t.Log("allkey", strings.Join(result, ",")) } else { t.Error(err.Error()) } if err := c.Redis.Set("test", []byte("dfdsiedskioe")); err != nil { t.Error(err.Error()) } if ss, err := c.Redis.Get("test"); err != nil { t.Error(err.Error()) } else { t.Log("test=", string(ss)) } //for i := 0; i < 100000; i++ { // c.Redis.Hset("tt", fmt.Sprintf("%s", i), []byte("test")) //} //for i := 0; i < 100000; i++ { // c.Redis.Set(fmt.Sprintf("teaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadsafsdafdsfdsafasdfdsafdsafsadfasfasfasfasfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaast%s", i), []byte("test")) //} c.Close() for i := 0; i < 100000; i++ { if cc, err := GetClient(fmt.Sprintf("%s", i)); err != nil { t.Error(err.Error()) } else { cc.Redis.Set(fmt.Sprintf("%s:%d", "teaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadsafsdafdsfdsafasdfdsafdsafsadfasfasfasfasfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaast", i), []byte("test")) cc.Close() } } } }