コード例 #1
0
ファイル: srv.go プロジェクト: tomlovzki/ebs
func RunSrv(args []string) {
	// netw.ShowLog = true
	// impl.ShowLog = true

	cfile := "conf/ebs.properties"
	if len(args) > 1 {
		cfile = args[1]
	}
	fmt.Println("Using config file:", cfile)
	err := conf.Cfg.InitWithFilePath(cfile)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	fmt.Println(dbMgr.Init("mysql", conf.DbConn()))

	p := pool.NewBytePool(8, 1024) //memory pool.
	l, cc, cms := impl.NewChanExecListener_m_j(p, conf.RC_ADDR(), netw.NewCWH(true))
	cms.AddHFunc("create-bank", CreateBank)
	cms.AddHFunc("edit-bank", EditBank)
	cms.AddHFunc("list-bank-question", ListBankQuestion)
	cms.AddHFunc("list-bank-paper", ListBankPaper)
	cms.AddHFunc("update-bank-paper", UpdateBankPaper)
	cms.AddHFunc("get-bank-paper-score", GetBankPaperScore)
	cms.AddHFunc("get-bank-item-cnt", GetBankItemCnt)
	cms.AddHFunc("get-usr-paper-record", GetUsrPaperRecord)
	cms.AddHFunc("attended-bank-info", AttendBankInfo)
	cc.Run(runtime.NumCPU() - 1) //start the chan distribution, if not start, sub handler will not receive message
	err = l.Run()                //run the listen server
	if err != nil {
		panic(err.Error())
	}
	l.Wait()
}
コード例 #2
0
ファイル: client_test.go プロジェクト: tomlovzki/ebs
func RunC() {
	p := pool.NewBytePool(8, 1024) //memory pool.
	l, con, err := impl.ExecDail_m_j(p, "127.0.0.1:9806", netw.NewCWH(true))
	if err != nil {
		panic(err.Error())
	}
	con.Start() //start handing the server reponse.if not start, exec will hang up.
	lc, rcm = l, con
}