You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
79 lines
1.9 KiB
package blockpay |
|
|
|
import ( |
|
"server/call" |
|
"server/config" |
|
"server/db" |
|
edb "server/db/es" |
|
mdb "server/db/mysql" |
|
rdb "server/db/redis" |
|
"strconv" |
|
"time" |
|
|
|
"github.com/liangdas/mqant/conf" |
|
"github.com/liangdas/mqant/log" |
|
"github.com/liangdas/mqant/module" |
|
basemodule "github.com/liangdas/mqant/module/base" |
|
"github.com/liangdas/mqant/server" |
|
) |
|
|
|
type Pay struct { |
|
basemodule.BaseModule |
|
} |
|
|
|
var Module = func() module.Module { |
|
this := new(Pay) |
|
return this |
|
} |
|
|
|
func (p *Pay) GetType() string { |
|
return "blockpay" |
|
} |
|
|
|
func (p *Pay) Version() string { |
|
//可以在监控时了解代码版本 |
|
return "1.0.0" |
|
} |
|
|
|
func (p *Pay) OnInit(app module.App, settings *conf.ModuleSettings) { |
|
metadata := make(map[string]string) |
|
metadata["workID"] = strconv.Itoa(int(config.GetConfig().WorkID)) |
|
p.BaseModule.OnInit(p, app, settings, |
|
server.RegisterInterval(5*time.Second), |
|
server.RegisterTTL(10*time.Second), |
|
server.Metadata(metadata), |
|
) |
|
call.NewCaller(p) |
|
db.InitDB(&mdb.MysqlClient{}, &rdb.RedisClient{}, &edb.EsClient{}) |
|
log.Info("[%v]module init finish, base:%+v", p.GetType(), config.GetBase()) |
|
|
|
if err := loadConfig(); err != nil { |
|
panic(err) |
|
} |
|
call.InitReload(p.App.Transport()) |
|
InitTron() |
|
|
|
p.GetServer().RegisterGO("recharge", Recharge) |
|
p.GetServer().RegisterGO("withdraw", Withdraw) |
|
p.GetServer().Register("queryOrder", QueryOrder) |
|
p.GetServer().Register("queryAddr", QueryLocalOfficialAddr) |
|
p.GetServer().Register("addAddr", AddLocalOfficialAddr) |
|
p.GetServer().Register("removeAddr", RemoveLocalOfficialAddr) |
|
p.GetServer().Register("transfer", Transfer) |
|
p.GetServer().Register("getFee", GetFee) |
|
p.GetServer().Register("scanPlayerWallet", ScanPlayerWallet) |
|
} |
|
|
|
func (p *Pay) Run(closeSig chan bool) { |
|
log.Info("[%v]module running", p.GetType()) |
|
<-closeSig |
|
log.Info("[%v]module stop", p.GetType()) |
|
} |
|
|
|
func (p *Pay) OnDestroy() { |
|
|
|
//一定别忘了继承 |
|
p.BaseModule.OnDestroy() |
|
|
|
log.Info("模块已销毁") |
|
}
|
|
|