This commit is contained in:
crusader 2018-05-11 17:20:11 +09:00
parent 9d30cf9726
commit 2469304d28
5 changed files with 28 additions and 25 deletions

View File

@ -2,3 +2,4 @@ package: git.loafle.net/overflow/probe_gateway_rpc
import: import:
- package: git.loafle.net/commons/server-go - package: git.loafle.net/commons/server-go
- package: git.loafle.net/commons/configuration-go - package: git.loafle.net/commons/configuration-go
- package: git.loafle.net/overflow/external-go

View File

@ -2,7 +2,7 @@ package server
import ( import (
cs "git.loafle.net/commons/server-go" cs "git.loafle.net/commons/server-go"
oge "git.loafle.net/overflow/gateway/external" oe "git.loafle.net/overflow/external-go"
ogrs "git.loafle.net/overflow/gateway_rpc/server" ogrs "git.loafle.net/overflow/gateway_rpc/server"
"git.loafle.net/overflow/probe_gateway_rpc/config" "git.loafle.net/overflow/probe_gateway_rpc/config"
"git.loafle.net/overflow/probe_gateway_rpc/subscribe" "git.loafle.net/overflow/probe_gateway_rpc/subscribe"
@ -22,7 +22,7 @@ func (sh *ServerHandlers) Init(serverCtx cs.ServerCtx) error {
if err := sh.ServerHandlers.Init(serverCtx); nil != err { if err := sh.ServerHandlers.Init(serverCtx); nil != err {
return err return err
} }
oge.InitPackage(sh.Config.External) oe.InitPackage(sh.Config.External)
subscribe.InitPackage() subscribe.InitPackage()
return nil return nil
@ -33,7 +33,7 @@ func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
return err return err
} }
oge.StartPackage(sh.Config.External) oe.StartPackage(sh.Config.External)
subscribe.StartPackage() subscribe.StartPackage()
return nil return nil
@ -41,14 +41,14 @@ func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
func (sh *ServerHandlers) OnStop(serverCtx cs.ServerCtx) { func (sh *ServerHandlers) OnStop(serverCtx cs.ServerCtx) {
subscribe.StopPackage() subscribe.StopPackage()
oge.StopPackage(sh.Config.External) oe.StopPackage(sh.Config.External)
sh.ServerHandlers.OnStop(serverCtx) sh.ServerHandlers.OnStop(serverCtx)
} }
func (sh *ServerHandlers) Destroy(serverCtx cs.ServerCtx) { func (sh *ServerHandlers) Destroy(serverCtx cs.ServerCtx) {
subscribe.DestroyPackage() subscribe.DestroyPackage()
oge.DestroyPackage(sh.Config.External) oe.DestroyPackage(sh.Config.External)
sh.ServerHandlers.Destroy(serverCtx) sh.ServerHandlers.Destroy(serverCtx)
} }

View File

@ -14,11 +14,12 @@ import (
occn "git.loafle.net/overflow/commons-go/config/noauthprobe" occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
ocmm "git.loafle.net/overflow/commons-go/model/meta" ocmm "git.loafle.net/overflow/commons-go/model/meta"
ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe" ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe"
oe "git.loafle.net/overflow/external-go"
oeg "git.loafle.net/overflow/external-go/grpc"
og "git.loafle.net/overflow/gateway" og "git.loafle.net/overflow/gateway"
"git.loafle.net/overflow/gateway/external/grpc"
ogs "git.loafle.net/overflow/gateway/subscribe" ogs "git.loafle.net/overflow/gateway/subscribe"
ogrs "git.loafle.net/overflow/gateway_rpc/servlet" ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
"git.loafle.net/overflow/probe_gateway_rpc/subscribe" opgrs "git.loafle.net/overflow/probe_gateway_rpc/subscribe"
) )
type AuthServlet interface { type AuthServlet interface {
@ -42,7 +43,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
return err return err
} }
subscribeChan, err := subscribe.Subscriber.Subscribe(occn.HTTPEntry_Auth) subscribeChan, err := opgrs.Subscriber.Subscribe(occn.HTTPEntry_Auth)
if nil != err { if nil != err {
return err return err
} }
@ -52,7 +53,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
} }
func (s *AuthServlets) OnStop(serverCtx server.ServerCtx) { func (s *AuthServlets) OnStop(serverCtx server.ServerCtx) {
if err := subscribe.Subscriber.Unsubscribe(occn.HTTPEntry_Auth); nil != err { if err := opgrs.Subscriber.Unsubscribe(occn.HTTPEntry_Auth); nil != err {
logging.Logger().Warn(err) logging.Logger().Warn(err)
} }
@ -85,7 +86,7 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
return nil, fmt.Errorf("Base64 Encoding Error: %s", err.Error()) return nil, fmt.Errorf("Base64 Encoding Error: %s", err.Error())
} }
grpcCTX := context.Background() grpcCTX := context.Background()
r, err := grpc.Exec(grpcCTX, "NoAuthProbeService.regist", string(rJSON)) r, err := oeg.Exec(grpcCTX, "NoAuthProbeService.regist", string(rJSON))
if nil != err { if nil != err {
return nil, fmt.Errorf("grpc call Error: %s", err.Error()) return nil, fmt.Errorf("grpc call Error: %s", err.Error())
} }
@ -101,7 +102,7 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
extHeader.Add(occn.HTTPResponseHeaderKey_NoAuthProbe_Method_Param, nap.TempProbeKey) extHeader.Add(occn.HTTPResponseHeaderKey_NoAuthProbe_Method_Param, nap.TempProbeKey)
servletCtx.SetAttribute(og.SessionIDKey, nap.TempProbeKey) servletCtx.SetAttribute(og.SessionIDKey, nap.TempProbeKey)
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE) servletCtx.SetAttribute(og.SessionClientTypeKey, oe.PROBE)
servletCtx.SetAttribute(og.SessionTargetIDKey, nap.TempProbeKey) servletCtx.SetAttribute(og.SessionTargetIDKey, nap.TempProbeKey)
return extHeader, nil return extHeader, nil
@ -113,7 +114,7 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
tempProbeKey := string(bTempProbeKey) tempProbeKey := string(bTempProbeKey)
grpcCTX := context.Background() grpcCTX := context.Background()
r, err := grpc.Exec(grpcCTX, "NoAuthProbeService.readByTempProbeKey", tempProbeKey) r, err := oeg.Exec(grpcCTX, "NoAuthProbeService.readByTempProbeKey", tempProbeKey)
if nil != err { if nil != err {
return nil, fmt.Errorf("grpc result error: %s", err.Error()) return nil, fmt.Errorf("grpc result error: %s", err.Error())
} }
@ -139,7 +140,7 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
} }
servletCtx.SetAttribute(og.SessionIDKey, tempProbeKey) servletCtx.SetAttribute(og.SessionIDKey, tempProbeKey)
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE) servletCtx.SetAttribute(og.SessionClientTypeKey, oe.PROBE)
servletCtx.SetAttribute(og.SessionTargetIDKey, tempProbeKey) servletCtx.SetAttribute(og.SessionTargetIDKey, tempProbeKey)
return extHeader, nil return extHeader, nil
@ -155,7 +156,7 @@ func (s *AuthServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn)
_tempProbeKey := servletCtx.GetAttribute(og.SessionIDKey) _tempProbeKey := servletCtx.GetAttribute(og.SessionIDKey)
if nil != _tempProbeKey { if nil != _tempProbeKey {
grpcCTX := context.Background() grpcCTX := context.Background()
_, err := grpc.Exec(grpcCTX, "NoAuthProbeService.onConnect", _tempProbeKey.(string), conn.RemoteAddr().String()) _, err := oeg.Exec(grpcCTX, "NoAuthProbeService.onConnect", _tempProbeKey.(string), conn.RemoteAddr().String())
if nil != err { if nil != err {
logging.Logger().Errorf("onConnect error %v", err) logging.Logger().Errorf("onConnect error %v", err)
} }
@ -168,7 +169,7 @@ func (s *AuthServlets) OnDisconnect(servletCtx server.ServletCtx) {
_tempProbeKey := servletCtx.GetAttribute(og.SessionIDKey) _tempProbeKey := servletCtx.GetAttribute(og.SessionIDKey)
if nil != _tempProbeKey { if nil != _tempProbeKey {
grpcCTX := context.Background() grpcCTX := context.Background()
_, err := grpc.Exec(grpcCTX, "NoAuthProbeService.onDisconnect", _tempProbeKey.(string)) _, err := oeg.Exec(grpcCTX, "NoAuthProbeService.onDisconnect", _tempProbeKey.(string))
if nil != err { if nil != err {
logging.Logger().Errorf("onDisconnect error %v", err) logging.Logger().Errorf("onDisconnect error %v", err)
} }

View File

@ -12,11 +12,12 @@ import (
"git.loafle.net/commons/server-go/socket" "git.loafle.net/commons/server-go/socket"
occp "git.loafle.net/overflow/commons-go/config/probe" occp "git.loafle.net/overflow/commons-go/config/probe"
ocmp "git.loafle.net/overflow/commons-go/model/probe" ocmp "git.loafle.net/overflow/commons-go/model/probe"
oe "git.loafle.net/overflow/external-go"
oeg "git.loafle.net/overflow/external-go/grpc"
og "git.loafle.net/overflow/gateway" og "git.loafle.net/overflow/gateway"
"git.loafle.net/overflow/gateway/external/grpc"
ogs "git.loafle.net/overflow/gateway/subscribe" ogs "git.loafle.net/overflow/gateway/subscribe"
ogrs "git.loafle.net/overflow/gateway_rpc/servlet" ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
"git.loafle.net/overflow/probe_gateway_rpc/subscribe" opgrs "git.loafle.net/overflow/probe_gateway_rpc/subscribe"
) )
type ProbeServlet interface { type ProbeServlet interface {
@ -40,7 +41,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
return err return err
} }
subscribeChan, err := subscribe.Subscriber.Subscribe(occp.HTTPEntry_Probe) subscribeChan, err := opgrs.Subscriber.Subscribe(occp.HTTPEntry_Probe)
if nil != err { if nil != err {
return err return err
} }
@ -50,7 +51,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
} }
func (s *ProbeServlets) OnStop(serverCtx server.ServerCtx) { func (s *ProbeServlets) OnStop(serverCtx server.ServerCtx) {
if err := subscribe.Subscriber.Unsubscribe(occp.HTTPEntry_Probe); nil != err { if err := opgrs.Subscriber.Unsubscribe(occp.HTTPEntry_Probe); nil != err {
logging.Logger().Warn(err) logging.Logger().Warn(err)
} }
@ -84,7 +85,7 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re
probeKey := string(bProbeKey) probeKey := string(bProbeKey)
grpcCTX := context.Background() grpcCTX := context.Background()
r, err := grpc.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey) r, err := oeg.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey)
if nil != err { if nil != err {
return nil, fmt.Errorf("grpc call Error: %s", err.Error()) return nil, fmt.Errorf("grpc call Error: %s", err.Error())
} }
@ -100,7 +101,7 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re
extHeader.Add(occp.HTTPResponseHeaderKey_Probe_Method_Param, probe.EncryptionKey) extHeader.Add(occp.HTTPResponseHeaderKey_Probe_Method_Param, probe.EncryptionKey)
servletCtx.SetAttribute(og.SessionIDKey, probeKey) servletCtx.SetAttribute(og.SessionIDKey, probeKey)
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE) servletCtx.SetAttribute(og.SessionClientTypeKey, oe.PROBE)
servletCtx.SetAttribute(og.SessionTargetIDKey, probeKey) servletCtx.SetAttribute(og.SessionTargetIDKey, probeKey)
return extHeader, nil return extHeader, nil
@ -112,7 +113,7 @@ func (s *ProbeServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn
_probeKey := servletCtx.GetAttribute(og.SessionIDKey) _probeKey := servletCtx.GetAttribute(og.SessionIDKey)
if nil != _probeKey { if nil != _probeKey {
grpcCTX := context.Background() grpcCTX := context.Background()
_, err := grpc.Exec(grpcCTX, "ProbeService.onConnect", _probeKey.(string), conn.RemoteAddr().String()) _, err := oeg.Exec(grpcCTX, "ProbeService.onConnect", _probeKey.(string), conn.RemoteAddr().String())
if nil != err { if nil != err {
logging.Logger().Errorf("onConnect error %v", err) logging.Logger().Errorf("onConnect error %v", err)
} }
@ -125,7 +126,7 @@ func (s *ProbeServlets) OnDisconnect(servletCtx server.ServletCtx) {
_probeKey := servletCtx.GetAttribute(og.SessionIDKey) _probeKey := servletCtx.GetAttribute(og.SessionIDKey)
if nil != _probeKey { if nil != _probeKey {
grpcCTX := context.Background() grpcCTX := context.Background()
_, err := grpc.Exec(grpcCTX, "ProbeService.onDisconnect", _probeKey.(string)) _, err := oeg.Exec(grpcCTX, "ProbeService.onDisconnect", _probeKey.(string))
if nil != err { if nil != err {
logging.Logger().Errorf("onDisconnect error %v", err) logging.Logger().Errorf("onDisconnect error %v", err)
} }

View File

@ -2,7 +2,7 @@ package subscribe
import ( import (
"git.loafle.net/commons/logging-go" "git.loafle.net/commons/logging-go"
oger "git.loafle.net/overflow/gateway/external/redis" oer "git.loafle.net/overflow/external-go/redis"
ogsr "git.loafle.net/overflow/gateway/subscribe/redis" ogsr "git.loafle.net/overflow/gateway/subscribe/redis"
) )
@ -10,7 +10,7 @@ var Subscriber *ogsr.Subscribers
func InitPackage() { func InitPackage() {
Subscriber = &ogsr.Subscribers{} Subscriber = &ogsr.Subscribers{}
Subscriber.Conn = oger.Pool.Get() Subscriber.Conn = oer.Pool.Get()
if err := Subscriber.Start(); nil != err { if err := Subscriber.Start(); nil != err {
logging.Logger().Panic(err) logging.Logger().Panic(err)
} }