代码拉取完成,页面将自动刷新
同步操作将从 Plato/Service-Box-go 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package sbox
import (
"io/fs"
"path/filepath"
"plugin"
"gitee.com/dennis-kk/rpc-go-backend/idlrpc"
"gitee.com/dennis-kk/service-box-go/util/tools"
)
func (sb *ServiceBox) loadAllService() error {
// load service from waitload pack aage
for n, p := range sb.waitLoadPack {
err := sb.loadServiceByPackInfo(p)
if err != nil {
sb.logger.Warn("%s load service from package error !", n)
continue
}
}
sb.waitLoadPack = make(packCache)
// if config service path, load from directory
// FIXME read from config
return sb.loadServiceFromDir("./Debug")
}
func (sb *ServiceBox) loadServiceFromDir(rootPath string) error {
//check file exist
if !tools.IsEffectiveDir(rootPath) {
sb.logger.Warn("no effective shared library storage path")
return nil
}
var bundles []string
err := filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
if err != nil {
//TODO add error log
return err
}
// skip root path
if path == rootPath {
return nil
}
//skip dir
if info.IsDir() {
return nil
}
if filepath.Ext(path) == ".so" {
bundles = append(bundles, path)
}
return nil
})
if err != nil {
//TODO add err log
return err
}
// open dll and get register function
for _, bundle := range bundles {
open, err := plugin.Open(bundle)
if err != nil {
//TODO add error log
continue
}
varHandle, err := open.Lookup("ServiceUUID")
if err != nil {
continue
}
funcHandle, err := open.Lookup("Creator")
if err != nil {
//TODO add error log
continue
}
//dynamic cast
if regHandle, ok := funcHandle.(idlrpc.SdkCreateHandle); ok {
srvUid := varHandle.(uint64)
srvPack := &idlrpc.PackageInfo{
ServiceUUID: srvUid,
Creator: regHandle,
}
err := sb.loadServiceByPackInfo(srvPack)
if err != nil {
sb.logger.Warn("%s load service lib error %v", bundle, err)
continue
}
sb.logger.Info("%s load service successful", bundle)
}
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。