Compare commits

...

5 Commits

Author SHA1 Message Date
orgin
be3daf19f9 优化服务配置获取函数 2022-06-09 17:44:42 +08:00
orgin
aa91c7bf1b Merge pull request #860 from cgc1983/master
module exit error
2022-06-09 11:52:50 +08:00
cgc1983
7fe73e55fb module exit error 2022-06-09 11:32:25 +08:00
cgc1983
e5ceaa9e76 ignore macosx 2022-06-02 17:51:03 +08:00
orgin
97c55ada71 优化网络连接Id生成规则 2022-06-02 17:07:01 +08:00
4 changed files with 76 additions and 84 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@
# Output of the go coverage tool, specifically when used with LiteIDE # Output of the go coverage tool, specifically when used with LiteIDE
*.out *.out
.DS_Store

View File

@@ -244,15 +244,6 @@ func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.
return nil, count return nil, count
} }
func (cls *Cluster) getServiceCfg(serviceName string) interface{} {
v, ok := cls.localServiceCfg[serviceName]
if ok == false {
return nil
}
return v
}
func (cls *Cluster) GetServiceCfg(serviceName string) interface{} { func (cls *Cluster) GetServiceCfg(serviceName string) interface{} {
serviceCfg, ok := cls.localServiceCfg[serviceName] serviceCfg, ok := cls.localServiceCfg[serviceName]
if ok == false { if ok == false {

View File

@@ -2,14 +2,16 @@ package service
import ( import (
"fmt" "fmt"
"reflect"
"sync/atomic"
"time"
"github.com/duanhf2012/origin/event" "github.com/duanhf2012/origin/event"
"github.com/duanhf2012/origin/log" "github.com/duanhf2012/origin/log"
rpcHandle "github.com/duanhf2012/origin/rpc" rpcHandle "github.com/duanhf2012/origin/rpc"
"github.com/duanhf2012/origin/util/timer" "github.com/duanhf2012/origin/util/timer"
"reflect"
"sync/atomic"
"time"
) )
const InitModuleId = 1e9 const InitModuleId = 1e9
type IModule interface { type IModule interface {
@@ -123,8 +125,8 @@ func (m *Module) ReleaseModule(moduleId uint32){
m.ReleaseModule(id) m.ReleaseModule(id)
} }
pModule.GetEventHandler().Destroy()
pModule.self.OnRelease() pModule.self.OnRelease()
pModule.GetEventHandler().Destroy()
log.SDebug("Release module ", pModule.GetModuleName()) log.SDebug("Release module ", pModule.GetModuleName())
for pTimer := range pModule.mapActiveTimer { for pTimer := range pModule.mapActiveTimer {
pTimer.Cancel() pTimer.Cancel()
@@ -155,6 +157,7 @@ func (m *Module) NewModuleId() uint32{
} }
var timerSeedId uint32 var timerSeedId uint32
func (m *Module) GenTimerId() uint64 { func (m *Module) GenTimerId() uint64 {
for { for {
newTimerId := (uint64(m.GetModuleId()) << 32) | uint64(atomic.AddUint32(&timerSeedId, 1)) newTimerId := (uint64(m.GetModuleId()) << 32) | uint64(atomic.AddUint32(&timerSeedId, 1))
@@ -166,7 +169,6 @@ func (m *Module) GenTimerId() uint64{
} }
} }
func (m *Module) GetAncestor() IModule { func (m *Module) GetAncestor() IModule {
return m.ancestor return m.ancestor
} }
@@ -287,8 +289,6 @@ func (m *Module) CancelTimerId(timerId *uint64) bool{
return true return true
} }
func (m *Module) OnRelease() { func (m *Module) OnRelease() {
} }

View File

@@ -74,7 +74,7 @@ func (tcpService *TcpService) genId() uint64 {
func GetNodeId(agentId uint64) int { func GetNodeId(agentId uint64) int {
return int(agentId>>54) return int(agentId>>50)
} }
func (tcpService *TcpService) OnInit() error{ func (tcpService *TcpService) OnInit() error{