ing
This commit is contained in:
parent
9c89a2fe90
commit
47d4a0b57d
|
@ -7,14 +7,14 @@ import (
|
|||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
||||
)
|
||||
|
||||
func NewSocketBuilder(napService *oopas.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func NewSocketBuilder(napService *oopas.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
*oopccc.SocketBuilders
|
||||
|
||||
napService *oopas.NoAuthProbeService
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -51,7 +51,6 @@ func init() {
|
|||
|
||||
configDir = oocc.FlagConfigDir()
|
||||
flag.Parse()
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
17
manager/central/central.go
Normal file
17
manager/central/central.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"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"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
*oopccc.SocketBuilders
|
||||
|
||||
napService *oops.NoAuthProbeService
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"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"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
*oopccc.SocketBuilders
|
||||
|
||||
napService *oops.NoAuthProbeService
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"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"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
|
||||
oops "git.loafle.net/overflow/overflow_probes/service"
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
*oopccc.SocketBuilders
|
||||
|
||||
napService *oops.NoAuthProbeService
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package container
|
||||
package client
|
||||
|
||||
import (
|
||||
crc "git.loafle.net/commons_go/rpc/client"
|
|
@ -1,4 +1,4 @@
|
|||
package container
|
||||
package client
|
||||
|
||||
import (
|
||||
crc "git.loafle.net/commons_go/rpc/client"
|
|
@ -1,4 +1,4 @@
|
|||
package container
|
||||
package client
|
||||
|
||||
import (
|
||||
"net"
|
|
@ -2,12 +2,13 @@ package container
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
crc "git.loafle.net/commons_go/rpc/client"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/client/container"
|
||||
oopmcc "git.loafle.net/overflow/overflow_probes/manager/container/client"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
|
@ -49,9 +50,14 @@ 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)
|
||||
sockArg := fmt.Sprintf("-sock=\"%s\"", sockFile)
|
||||
|
||||
cmd := exec.Command("", sockArg)
|
||||
if err := cmd.Start(); nil != err {
|
||||
|
@ -64,13 +70,31 @@ func (cm *containerManager) runProcess(name string) error {
|
|||
socketName: sockFile,
|
||||
pid: cmd.Process.Pid,
|
||||
}
|
||||
cs.client = oopcc.New(sockFile, nil)
|
||||
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) {
|
||||
|
||||
// }
|
||||
|
@ -80,6 +104,3 @@ func (cm *containerManager) runProcess(name string) error {
|
|||
// func (cm *containerManager) {
|
||||
|
||||
// }
|
||||
// func (cm *containerManager) {
|
||||
|
||||
// }
|
||||
|
|
|
@ -2,44 +2,44 @@ package service
|
|||
|
||||
import (
|
||||
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
|
||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||
oopmc "git.loafle.net/overflow/overflow_probes/manager/container"
|
||||
oopmCentral "git.loafle.net/overflow/overflow_probes/manager/central"
|
||||
oopmContainer "git.loafle.net/overflow/overflow_probes/manager/container"
|
||||
)
|
||||
|
||||
type DiscoveryService struct {
|
||||
ProbeClient oogwc.Client `annotation:"@inject{name:probeClient}"`
|
||||
ContainerManager oopmc.ContainerManager `annotation:"@inject{name:containerManager}"`
|
||||
CentralManager oopmCentral.CentralManager `annotation:"@inject{name:probeClient}"`
|
||||
ContainerManager oopmContainer.ContainerManager `annotation:"@inject{name:containerManager}"`
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoverZone(dz *discoveryM.DiscoveryZone) error {
|
||||
return ds.ContainerManager.GetClient().Send("DiscoveryService.DiscoverZone", dz)
|
||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverZone", dz)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
|
||||
return ds.ContainerManager.GetClient().Send("DiscoveryService.DiscoverHost", zone, dh)
|
||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverHost", zone, dh)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
|
||||
return ds.ContainerManager.GetClient().Send("DiscoveryService.DiscoverPort", host, dp)
|
||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverPort", host, dp)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, ds *discoveryM.DiscoveryService) error {
|
||||
return ds.ContainerManager.GetClient().Send("DiscoveryService.DiscoverZone", port, ds)
|
||||
func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
|
||||
return ds.ContainerManager.GetClient("").Send("DiscoveryService.DiscoverZone", port, dService)
|
||||
}
|
||||
|
||||
// use by discovery
|
||||
func (ds *DiscoveryService) DiscoveredZone(zone *discoveryM.Zone) error {
|
||||
return ds.ProbeClient.Send("DiscoveryService.DiscoveredZone", zone)
|
||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredZone", zone)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoveredHost(host *discoveryM.Host) error {
|
||||
return ds.ProbeClient.Send("DiscoveryService.DiscoveredHost", host)
|
||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredHost", host)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoveredPort(port *discoveryM.Port) error {
|
||||
return ds.ProbeClient.Send("DiscoveryService.DiscoveredPort", port)
|
||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredPort", port)
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) DiscoveredService(service *discoveryM.Service) error {
|
||||
return ds.ProbeClient.Send("DiscoveryService.DiscoveredService", service)
|
||||
return ds.CentralManager.GetClient("").Send("DiscoveryService.DiscoveredService", service)
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@ type LogService struct {
|
|||
}
|
||||
|
||||
func (ls *LogService) Send() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ type ProbeService struct {
|
|||
}
|
||||
|
||||
func (ps *ProbeService) Start() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
func (ps *ProbeService) Stop() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
func (ps *ProbeService) Update() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model"
|
||||
)
|
||||
|
||||
type SensorService struct {
|
||||
}
|
||||
|
||||
func (ss *SensorService) Start(id int64) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ss *SensorService) Stop(id int64) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ss *SensorService) Add(config *configM.Config) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ss *SensorService) Remove(id int64) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ss *SensorService) Update(id int64) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user