ing
This commit is contained in:
parent
47d4a0b57d
commit
fb7d1ca4d6
|
@ -18,6 +18,7 @@ func NewSocketBuilder(napService *oopas.NoAuthProbeService) cwfc.SocketBuilder {
|
||||||
if nil == sb.SocketBuilders {
|
if nil == sb.SocketBuilders {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
sb.SocketHandler = newSocketHandler(sb.napService)
|
||||||
|
|
||||||
return sb
|
return sb
|
||||||
}
|
}
|
||||||
|
@ -28,10 +29,6 @@ type SocketBuilders struct {
|
||||||
napService *oopas.NoAuthProbeService
|
napService *oopas.NoAuthProbeService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
|
||||||
return newSocketHandler(sb.napService)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
||||||
h := sb.napService.GetRequestHeader()
|
h := sb.napService.GetRequestHeader()
|
||||||
header := http.Header{}
|
header := http.Header{}
|
||||||
|
|
11
client/central/data/client.go
Normal file
11
client/central/data/client.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New() oogwc.Client {
|
||||||
|
ch := newClientHandler()
|
||||||
|
sb := newSocketBuilder()
|
||||||
|
return oogwc.New(ch, sb)
|
||||||
|
}
|
|
@ -5,13 +5,12 @@ import (
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
crr "git.loafle.net/commons_go/rpc/registry"
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClientHandler(rpcInvoker crr.RPCInvoker) oogwc.ClientHandler {
|
func newClientHandler() oogwc.ClientHandler {
|
||||||
ch := &ClientHandlers{}
|
ch := &ClientHandlers{}
|
||||||
ch.ClientHandler = oogwc.NewClientHandler(rpcInvoker)
|
ch.ClientHandler = oogwc.NewClientHandler(nil)
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
@ -21,11 +20,11 @@ type ClientHandlers struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ch *ClientHandlers) Init(clientCTX crc.ClientContext) error {
|
func (ch *ClientHandlers) Init(clientCTX crc.ClientContext) error {
|
||||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been initialized"))
|
logging.Logger().Info(fmt.Sprintf("Probe Data: client has been initialized"))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ch *ClientHandlers) Destroy(clientCTX crc.ClientContext) {
|
func (ch *ClientHandlers) Destroy(clientCTX crc.ClientContext) {
|
||||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been destroyed"))
|
logging.Logger().Info(fmt.Sprintf("Probe Data: client has been destroyed"))
|
||||||
}
|
}
|
27
client/central/data/socket_builders.go
Normal file
27
client/central/data/socket_builders.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||||
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
|
oopcc "git.loafle.net/overflow/overflow_probes/client/central"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSocketBuilder() cwfc.SocketBuilder {
|
||||||
|
sb := &SocketBuilders{}
|
||||||
|
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||||
|
if nil == sb.SocketBuilders {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
sb.SocketHandler = newSocketHandler()
|
||||||
|
|
||||||
|
return sb
|
||||||
|
}
|
||||||
|
|
||||||
|
type SocketBuilders struct {
|
||||||
|
*oopcc.SocketBuilders
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sb *SocketBuilders) Validate() {
|
||||||
|
sb.SocketBuilders.Validate()
|
||||||
|
|
||||||
|
}
|
27
client/central/data/socket_handlers.go
Normal file
27
client/central/data/socket_handlers.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.loafle.net/commons_go/logging"
|
||||||
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SocketHandlers struct {
|
||||||
|
cwfc.SocketHandlers
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
||||||
|
logging.Logger().Info(fmt.Sprintf("Probe: client has been connected res[%v]", res))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
||||||
|
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSocketHandler() cwfc.SocketHandler {
|
||||||
|
return &SocketHandlers{}
|
||||||
|
}
|
12
client/central/probe/client.go
Normal file
12
client/central/probe/client.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New(rpcInvoker crr.RPCInvoker) oogwc.Client {
|
||||||
|
ch := newClientHandler(rpcInvoker)
|
||||||
|
sb := newSocketBuilder()
|
||||||
|
return oogwc.New(ch, sb)
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ import (
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClientHandler(rpcInvoker crr.RPCInvoker) oogwc.ClientHandler {
|
func newClientHandler(rpcInvoker crr.RPCInvoker) oogwc.ClientHandler {
|
||||||
ch := &ClientHandlers{}
|
ch := &ClientHandlers{}
|
||||||
ch.ClientHandler = oogwc.NewClientHandler(rpcInvoker)
|
ch.ClientHandler = oogwc.NewClientHandler(rpcInvoker)
|
||||||
|
|
27
client/central/probe/socket_builders.go
Normal file
27
client/central/probe/socket_builders.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||||
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
|
oopcc "git.loafle.net/overflow/overflow_probes/client/central"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSocketBuilder() cwfc.SocketBuilder {
|
||||||
|
sb := &SocketBuilders{}
|
||||||
|
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||||
|
if nil == sb.SocketBuilders {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
sb.SocketHandler = newSocketHandler()
|
||||||
|
|
||||||
|
return sb
|
||||||
|
}
|
||||||
|
|
||||||
|
type SocketBuilders struct {
|
||||||
|
*oopcc.SocketBuilders
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sb *SocketBuilders) Validate() {
|
||||||
|
sb.SocketBuilders.Validate()
|
||||||
|
|
||||||
|
}
|
31
client/central/probe/socket_handlers.go
Normal file
31
client/central/probe/socket_handlers.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.loafle.net/commons_go/logging"
|
||||||
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||||
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SocketHandlers struct {
|
||||||
|
cwfc.SocketHandlers
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
||||||
|
logging.Logger().Info(fmt.Sprintf("Probe: client has been connected res[%v]", res))
|
||||||
|
|
||||||
|
encryptionKey := res.Header.Get(oocmp.HTTPResponseHeaderKey_Probe_SetEncryptionKey)
|
||||||
|
config.EncryptionKey = &encryptionKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
||||||
|
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSocketHandler() cwfc.SocketHandler {
|
||||||
|
return &SocketHandlers{}
|
||||||
|
}
|
35
client/central/socket_builders.go
Normal file
35
client/central/socket_builders.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package central
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
|
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
||||||
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewSocketBuilder(entryPath string) *SocketBuilders {
|
||||||
|
sb := &SocketBuilders{}
|
||||||
|
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||||
|
if nil == sb.SocketBuilders {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb
|
||||||
|
}
|
||||||
|
|
||||||
|
type SocketBuilders struct {
|
||||||
|
*oopccc.SocketBuilders
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
||||||
|
header := http.Header{}
|
||||||
|
header.Set(oocmp.HTTPRequestHeaderKey_Probe_Method, oocmp.HTTPRequestHeaderValue_Probe_Method_Connect)
|
||||||
|
header.Set(oocmp.HTTPRequestHeaderKey_Probe_ProbeKey, *config.Config.Probe.Key)
|
||||||
|
return header
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sb *SocketBuilders) Validate() {
|
||||||
|
sb.SocketBuilders.Validate()
|
||||||
|
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
cunu "git.loafle.net/commons_go/util/net/url"
|
cunu "git.loafle.net/commons_go/util/net/url"
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||||
|
|
||||||
"git.loafle.net/overflow/overflow_probes/config"
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +13,7 @@ func NewSocketBuilder(entryPath string) *SocketBuilders {
|
||||||
sb := &SocketBuilders{}
|
sb := &SocketBuilders{}
|
||||||
url, err := cunu.Join(config.Config.Central.URL, entryPath)
|
url, err := cunu.Join(config.Config.Central.URL, entryPath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.Logger().Error(fmt.Sprintf("Auth: Cannot create SocketBuilder %v", err))
|
logging.Logger().Error(fmt.Sprintf("Probe: Cannot create SocketBuilder %v", err))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
sb.URL = url
|
sb.URL = url
|
||||||
|
@ -26,3 +25,8 @@ func NewSocketBuilder(entryPath string) *SocketBuilders {
|
||||||
type SocketBuilders struct {
|
type SocketBuilders struct {
|
||||||
cwfc.SocketBuilders
|
cwfc.SocketBuilders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sb *SocketBuilders) Validate() {
|
||||||
|
sb.SocketBuilders.Validate()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,5 +4,11 @@
|
||||||
"apiKey": "52abd6fd57e511e7ac52080027658d13",
|
"apiKey": "52abd6fd57e511e7ac52080027658d13",
|
||||||
"readBufferSize": 8192,
|
"readBufferSize": 8192,
|
||||||
"writeBufferSize": 8192
|
"writeBufferSize": 8192
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"root": "",
|
||||||
|
"bin": "bin",
|
||||||
|
"config": "config",
|
||||||
|
"pid": "pid"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
package central
|
|
||||||
|
|
||||||
import (
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CentralManager interface {
|
|
||||||
GetClient(name string) oogwc.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
type centralManager struct {
|
|
||||||
clients map[string]oogwc.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *centralManager) GetClient(entryPath string) oogwc.Client {
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package data
|
|
||||||
|
|
||||||
import (
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewClient(ch oogwc.ClientHandler, sb cwfc.SocketBuilder) oogwc.Client {
|
|
||||||
|
|
||||||
return oogwc.New(ch, sb)
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package data
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
|
||||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|
||||||
sb := &SocketBuilders{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
|
||||||
if nil == sb.SocketBuilders {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb
|
|
||||||
}
|
|
||||||
|
|
||||||
type SocketBuilders struct {
|
|
||||||
*oopccc.SocketBuilders
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
|
||||||
return newSocketHandler(sb.napService)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
|
||||||
h := sb.napService.GetRequestHeader()
|
|
||||||
header := http.Header{}
|
|
||||||
for k, v := range h {
|
|
||||||
header[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
return header
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) Validate() {
|
|
||||||
sb.SocketBuilders.Validate()
|
|
||||||
|
|
||||||
if nil == sb.napService {
|
|
||||||
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package data
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
|
||||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SocketHandlers struct {
|
|
||||||
cwfc.SocketHandlers
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been connected res[%v]", res))
|
|
||||||
|
|
||||||
switch sh.napService.Config.State() {
|
|
||||||
case ooccn.NoAuthProbeStateTypeNotRegisterd:
|
|
||||||
tempProbeKey := res.Header.Get(oocmn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey)
|
|
||||||
sh.napService.SetTempProbeKey(tempProbeKey)
|
|
||||||
case ooccn.NoAuthProbeStateTypeRegisterd:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func newSocketHandler(napService *oops.NoAuthProbeService) cwfc.SocketHandler {
|
|
||||||
return &SocketHandlers{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package file
|
|
||||||
|
|
||||||
import (
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewClient(ch oogwc.ClientHandler, sb cwfc.SocketBuilder) oogwc.Client {
|
|
||||||
|
|
||||||
return oogwc.New(ch, sb)
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package file
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
|
||||||
crr "git.loafle.net/commons_go/rpc/registry"
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewClientHandler(rpcInvoker crr.RPCInvoker) oogwc.ClientHandler {
|
|
||||||
ch := &ClientHandlers{}
|
|
||||||
ch.ClientHandler = oogwc.NewClientHandler(rpcInvoker)
|
|
||||||
|
|
||||||
return ch
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClientHandlers struct {
|
|
||||||
oogwc.ClientHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ch *ClientHandlers) Init(clientCTX crc.ClientContext) error {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been initialized"))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ch *ClientHandlers) Destroy(clientCTX crc.ClientContext) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been destroyed"))
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package file
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
|
||||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|
||||||
sb := &SocketBuilders{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
|
||||||
if nil == sb.SocketBuilders {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb
|
|
||||||
}
|
|
||||||
|
|
||||||
type SocketBuilders struct {
|
|
||||||
*oopccc.SocketBuilders
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
|
||||||
return newSocketHandler(sb.napService)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
|
||||||
h := sb.napService.GetRequestHeader()
|
|
||||||
header := http.Header{}
|
|
||||||
for k, v := range h {
|
|
||||||
header[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
return header
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) Validate() {
|
|
||||||
sb.SocketBuilders.Validate()
|
|
||||||
|
|
||||||
if nil == sb.napService {
|
|
||||||
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package file
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
|
||||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SocketHandlers struct {
|
|
||||||
cwfc.SocketHandlers
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been connected res[%v]", res))
|
|
||||||
|
|
||||||
switch sh.napService.Config.State() {
|
|
||||||
case ooccn.NoAuthProbeStateTypeNotRegisterd:
|
|
||||||
tempProbeKey := res.Header.Get(oocmn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey)
|
|
||||||
sh.napService.SetTempProbeKey(tempProbeKey)
|
|
||||||
case ooccn.NoAuthProbeStateTypeRegisterd:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func newSocketHandler(napService *oops.NoAuthProbeService) cwfc.SocketHandler {
|
|
||||||
return &SocketHandlers{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package probe
|
|
||||||
|
|
||||||
import (
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewClient(ch oogwc.ClientHandler, sb cwfc.SocketBuilder) oogwc.Client {
|
|
||||||
|
|
||||||
return oogwc.New(ch, sb)
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package probe
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
|
||||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|
||||||
sb := &SocketBuilders{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
|
||||||
if nil == sb.SocketBuilders {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb
|
|
||||||
}
|
|
||||||
|
|
||||||
type SocketBuilders struct {
|
|
||||||
*oopccc.SocketBuilders
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
|
||||||
return newSocketHandler(sb.napService)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
|
||||||
h := sb.napService.GetRequestHeader()
|
|
||||||
header := http.Header{}
|
|
||||||
for k, v := range h {
|
|
||||||
header[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
return header
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SocketBuilders) Validate() {
|
|
||||||
sb.SocketBuilders.Validate()
|
|
||||||
|
|
||||||
if nil == sb.napService {
|
|
||||||
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package probe
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
||||||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
|
||||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
|
||||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SocketHandlers struct {
|
|
||||||
cwfc.SocketHandlers
|
|
||||||
|
|
||||||
napService *oops.NoAuthProbeService
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been connected res[%v]", res))
|
|
||||||
|
|
||||||
switch sh.napService.Config.State() {
|
|
||||||
case ooccn.NoAuthProbeStateTypeNotRegisterd:
|
|
||||||
tempProbeKey := res.Header.Get(oocmn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey)
|
|
||||||
sh.napService.SetTempProbeKey(tempProbeKey)
|
|
||||||
case ooccn.NoAuthProbeStateTypeRegisterd:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func newSocketHandler(napService *oops.NoAuthProbeService) cwfc.SocketHandler {
|
|
||||||
return &SocketHandlers{
|
|
||||||
napService: napService,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,106 +0,0 @@
|
||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
|
||||||
oopmcc "git.loafle.net/overflow/overflow_probes/manager/container/client"
|
|
||||||
uuid "github.com/satori/go.uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ContainerManager interface {
|
|
||||||
GetClient(name string) crc.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
type containerManager struct {
|
|
||||||
containerClients map[string]*containerState
|
|
||||||
}
|
|
||||||
|
|
||||||
type containerState struct {
|
|
||||||
socketName string
|
|
||||||
pid int
|
|
||||||
client crc.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) GetClient(name string) crc.Client {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) CheckClient(name string) bool {
|
|
||||||
cs, ok := cm.containerClients[name]
|
|
||||||
if !ok || nil == cs || nil == cs.client {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
stateOk := false
|
|
||||||
if err := cs.client.Call(&stateOk, "StateService.State"); nil != err {
|
|
||||||
logging.Logger().Error(fmt.Sprintf("Probe: Call[%s(%s)] err %v", name, "StateService.State", err))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateOk
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) ConnectClient(name string) error {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) CloseClient(name string) error {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) runProcess(name string) error {
|
|
||||||
sockFile := uuid.NewV4().String()
|
|
||||||
sockArg := fmt.Sprintf("-sock=\"%s\"", sockFile)
|
|
||||||
|
|
||||||
cmd := exec.Command("", sockArg)
|
|
||||||
if err := cmd.Start(); nil != err {
|
|
||||||
logging.Logger().Error(fmt.Sprintf("Probe: To run container(%s) failed err %v", name, err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
time.Sleep(time.Duration(time.Second * 2))
|
|
||||||
|
|
||||||
cs := &containerState{
|
|
||||||
socketName: sockFile,
|
|
||||||
pid: cmd.Process.Pid,
|
|
||||||
}
|
|
||||||
cs.client = oopmcc.New(sockFile, nil)
|
|
||||||
// write pid file
|
|
||||||
cm.containerClients[name] = cs
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cm *containerManager) stopProcess(name string) error {
|
|
||||||
cs, ok := cm.containerClients[name]
|
|
||||||
if !ok || nil == cs || nil == cs.client {
|
|
||||||
return fmt.Errorf("Probe: Container[%s] is not exist", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
p, err := os.FindProcess(cs.pid)
|
|
||||||
if nil != err {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = p.Kill(); nil != err {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// remove pid file
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// func (cm *containerManager) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// func (cm *containerManager) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// func (cm *containerManager) {
|
|
||||||
|
|
||||||
// }
|
|
|
@ -6,7 +6,10 @@ import (
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
crr "git.loafle.net/commons_go/rpc/registry"
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
|
oopccd "git.loafle.net/overflow/overflow_probes/client/central/data"
|
||||||
|
oopccp "git.loafle.net/overflow/overflow_probes/client/central/probe"
|
||||||
|
"git.loafle.net/overflow/overflow_probes/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() ProbeManager {
|
func New() ProbeManager {
|
||||||
|
@ -21,8 +24,6 @@ type ProbeManager interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type probeManagers struct {
|
type probeManagers struct {
|
||||||
cClient oogwc.Client
|
|
||||||
|
|
||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
stopWg sync.WaitGroup
|
stopWg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
@ -32,21 +33,28 @@ func (pm *probeManagers) Start() error {
|
||||||
logging.Logger().Panic("Probe: already running. Stop it before starting it again")
|
logging.Logger().Panic("Probe: already running. Stop it before starting it again")
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcRegistry := crr.NewRPCRegistry()
|
probeRPCRegistry := crr.NewRPCRegistry()
|
||||||
|
probeRPCRegistry.RegisterService(&service.CentralService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.ConfigService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.CrawlerService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.DiscoveryService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.LogService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.ProbeService{}, "")
|
||||||
|
probeRPCRegistry.RegisterService(&service.SensorService{}, "")
|
||||||
|
|
||||||
// napService := &oopar.NoAuthProbeService{
|
centralProbeClient := oopccp.New(probeRPCRegistry)
|
||||||
// DoneChan: pm.serviceDoneChan,
|
if err := centralProbeClient.Connect(); nil != err {
|
||||||
// ConfigPath: pm.configPath,
|
return err
|
||||||
// Config: pm.config,
|
}
|
||||||
// }
|
|
||||||
// rpcRegistry.RegisterService(napService, "")
|
|
||||||
|
|
||||||
// ch := client.NewClientHandler(rpcRegistry)
|
centralDataClient := oopccd.New()
|
||||||
// sb := client.NewSocketBuilder(napService)
|
if err := centralDataClient.Connect(); nil != err {
|
||||||
// if nil == sb {
|
return err
|
||||||
// return fmt.Errorf("Auth: Cannot create SocketBuilder")
|
}
|
||||||
// }
|
|
||||||
// pm.cClient = client.NewClient(ch, sb)
|
centralS := probeRPCRegistry.GetService("CentralService").(*service.CentralService)
|
||||||
|
centralS.PutClient(oocmp.HTTPEntry_Probe, centralProbeClient)
|
||||||
|
centralS.PutClient(oocmp.HTTPEntry_Data, centralDataClient)
|
||||||
|
|
||||||
pm.stopChan = make(chan struct{})
|
pm.stopChan = make(chan struct{})
|
||||||
|
|
||||||
|
@ -58,28 +66,28 @@ func (pm *probeManagers) Start() error {
|
||||||
|
|
||||||
func (pm *probeManagers) Stop() {
|
func (pm *probeManagers) Stop() {
|
||||||
if pm.stopChan == nil {
|
if pm.stopChan == nil {
|
||||||
logging.Logger().Warn("Auth: auth must be started before stopping it")
|
logging.Logger().Warn("Probe: probe must be started before stopping it")
|
||||||
}
|
}
|
||||||
close(pm.stopChan)
|
close(pm.stopChan)
|
||||||
pm.stopWg.Wait()
|
pm.stopWg.Wait()
|
||||||
pm.stopChan = nil
|
pm.stopChan = nil
|
||||||
|
|
||||||
pm.cClient.Close()
|
// pm.cClient.Close()
|
||||||
|
|
||||||
logging.Logger().Info(fmt.Sprintf("Auth: stopped"))
|
logging.Logger().Info(fmt.Sprintf("Probe: stopped"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *probeManagers) handleProbe() {
|
func (pm *probeManagers) handleProbe() {
|
||||||
var err error
|
// var err error
|
||||||
defer func() {
|
defer func() {
|
||||||
pm.stopWg.Done()
|
pm.stopWg.Done()
|
||||||
pm.Stop()
|
pm.Stop()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err = pm.cClient.Connect(); nil != err {
|
// if err = pm.cClient.Connect(); nil != err {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
55
service/CentralService.go
Normal file
55
service/CentralService.go
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CentralService struct {
|
||||||
|
clients map[string]oogwc.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) PutClient(entryPath string, c oogwc.Client) {
|
||||||
|
cs.clients[entryPath] = c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) Call(entryPath string, result interface{}, method string, params ...interface{}) error {
|
||||||
|
c := cs.GetClient(entryPath)
|
||||||
|
return c.Call(result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) Send(entryPath string, method string, params ...interface{}) error {
|
||||||
|
c := cs.GetClient(entryPath)
|
||||||
|
|
||||||
|
return c.Send(method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) GetClient(entryPath string) oogwc.Client {
|
||||||
|
return cs.clients[entryPath]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) CheckClient(entryPath string) bool {
|
||||||
|
c, ok := cs.clients[entryPath]
|
||||||
|
if !ok || nil == c {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CentralService) Connect(entryPath string) error {
|
||||||
|
// var c oogwc.Client
|
||||||
|
// switch entryPath {
|
||||||
|
// case oocmp.HTTPEntry_Probe:
|
||||||
|
// c = oopccp.NewClient()
|
||||||
|
// case oocmp.HTTPEntry_Data:
|
||||||
|
// c = oopccd.NewClient()
|
||||||
|
// case oocmp.HTTPEntry_File:
|
||||||
|
// c = oopccf.NewClient()
|
||||||
|
// default:
|
||||||
|
// return fmt.Errorf("Gateway entry[%s] is not exist", entryPath)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cs.clients[entryPath] = c
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
91
service/ContainerService.go
Normal file
91
service/ContainerService.go
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContainerService struct {
|
||||||
|
clients map[string]*containerState
|
||||||
|
}
|
||||||
|
|
||||||
|
type containerState struct {
|
||||||
|
socketName string
|
||||||
|
pid int
|
||||||
|
client crc.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) Call(name string, result interface{}, method string, params ...interface{}) error {
|
||||||
|
c, err := cs.GetClient(name)
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.Call(result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) Send(name string, method string, params ...interface{}) error {
|
||||||
|
c, err := cs.GetClient(name)
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.Send(method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) GetClient(name string) (crc.Client, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) Connect(name string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) runProcess(name string) error {
|
||||||
|
ok := cs.checkProcess(name)
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// runCmd := config.Config.Paths["root"] + "/" + config.Config.Paths["bin"] + "/" + name + "/start"
|
||||||
|
|
||||||
|
// sockFile := uuid.NewV4().String()
|
||||||
|
// sockArg := fmt.Sprintf("-sock=\"%s\"", sockFile)
|
||||||
|
|
||||||
|
// cmd := exec.Command(runCmd, sockArg)
|
||||||
|
// if err := cmd.Start(); nil != err {
|
||||||
|
// logging.Logger().Error(fmt.Sprintf("Probe: To run container(%s) failed err %v", name, err))
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// time.Sleep(time.Duration(time.Second * 2))
|
||||||
|
|
||||||
|
// cs := &containerState{
|
||||||
|
// socketName: sockFile,
|
||||||
|
// pid: cmd.Process.Pid,
|
||||||
|
// }
|
||||||
|
// cs.client = oopmcc.New(sockFile, nil)
|
||||||
|
// // write pid file
|
||||||
|
// cs.containerClients[name] = cs
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) checkProcess(name string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerService) killProcess(name string) error {
|
||||||
|
// cs, ok := cs.containerClients[name]
|
||||||
|
// if !ok || nil == cs || nil == cs.client {
|
||||||
|
// return fmt.Errorf("Probe: Container[%s] is not exist", name)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// p, err := os.FindProcess(cs.pid)
|
||||||
|
// if nil != err {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if err = p.Kill(); nil != err {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// // remove pid file
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -2,13 +2,9 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model"
|
configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model"
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
|
||||||
oopmc "git.loafle.net/overflow/overflow_probes/manager/container"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CrawlerService struct {
|
type CrawlerService struct {
|
||||||
ProbeClient oogwc.Client `annotation:"@inject{name:probeClient}"`
|
|
||||||
ContainerManager oopmc.ContainerManager `annotation:"@inject{name:containerManager}"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CrawlerService) Install() error {
|
func (cs *CrawlerService) Install() error {
|
||||||
|
|
|
@ -2,44 +2,44 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
|
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
|
||||||
oopmCentral "git.loafle.net/overflow/overflow_probes/manager/central"
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
oopmContainer "git.loafle.net/overflow/overflow_probes/manager/container"
|
oocmpsp "git.loafle.net/overflow/overflow_commons_go/modules/probe/service/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiscoveryService struct {
|
type DiscoveryService struct {
|
||||||
CentralManager oopmCentral.CentralManager `annotation:"@inject{name:probeClient}"`
|
ContainerService *ContainerService `annotation:"@Inject()"`
|
||||||
ContainerManager oopmContainer.ContainerManager `annotation:"@inject{name:containerManager}"`
|
CentralService *CentralService `annotation:"@Inject()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoverZone(dz *discoveryM.DiscoveryZone) error {
|
func (ds *DiscoveryService) DiscoverZone(dz *discoveryM.DiscoveryZone) error {
|
||||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverZone", dz)
|
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", dz)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
|
func (ds *DiscoveryService) DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
|
||||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverHost", zone, dh)
|
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverHost", zone, dh)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
|
func (ds *DiscoveryService) DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
|
||||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverPort", host, dp)
|
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverPort", host, dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
|
func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
|
||||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverZone", port, dService)
|
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", port, dService)
|
||||||
}
|
}
|
||||||
|
|
||||||
// use by discovery
|
// use by discovery
|
||||||
func (ds *DiscoveryService) DiscoveredZone(zone *discoveryM.Zone) error {
|
func (ds *DiscoveryService) DiscoveredZone(zone *discoveryM.Zone) error {
|
||||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredZone", zone)
|
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredZone", zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoveredHost(host *discoveryM.Host) error {
|
func (ds *DiscoveryService) DiscoveredHost(host *discoveryM.Host) error {
|
||||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredHost", host)
|
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredHost", host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoveredPort(port *discoveryM.Port) error {
|
func (ds *DiscoveryService) DiscoveredPort(port *discoveryM.Port) error {
|
||||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredPort", port)
|
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredPort", port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DiscoveryService) DiscoveredService(service *discoveryM.Service) error {
|
func (ds *DiscoveryService) DiscoveredService(service *discoveryM.Service) error {
|
||||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredService", service)
|
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredService", service)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user