ing
This commit is contained in:
parent
6bcb527545
commit
ca25ad0f57
86
auth/auth.go
86
auth/auth.go
|
@ -11,16 +11,22 @@ import (
|
|||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||
"git.loafle.net/overflow/overflow_probes/auth/client"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
||||
"git.loafle.net/overflow/overflow_probes/config"
|
||||
)
|
||||
|
||||
type Auther interface {
|
||||
func New() AuthManager {
|
||||
am := &authManagers{}
|
||||
|
||||
return am
|
||||
}
|
||||
|
||||
type AuthManager interface {
|
||||
EndableStart(doneChan chan<- error) error
|
||||
Stop()
|
||||
}
|
||||
|
||||
type auth struct {
|
||||
type authManagers struct {
|
||||
doneChan chan<- error
|
||||
|
||||
cClient oogwc.Client
|
||||
|
@ -34,38 +40,32 @@ type auth struct {
|
|||
stopWg sync.WaitGroup
|
||||
}
|
||||
|
||||
func New() Auther {
|
||||
a := &auth{}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *auth) EndableStart(doneChan chan<- error) error {
|
||||
if nil != a.stopChan {
|
||||
func (am *authManagers) EndableStart(doneChan chan<- error) error {
|
||||
if nil != am.stopChan {
|
||||
logging.Logger().Panic("Auth: auth is already running. Stop it before starting it again")
|
||||
}
|
||||
|
||||
a.configPath = path.Join(*config.ConfigDir, ooccn.ConfigFileName)
|
||||
am.configPath = path.Join(*config.ConfigDir, ooccn.ConfigFileName)
|
||||
|
||||
conf := cc.New()
|
||||
if cc.Exists(a.configPath) {
|
||||
if err := conf.Load(&a.config, a.configPath); nil != err {
|
||||
return fmt.Errorf("Auth: Loading of NoAuth config file[%s] failed error[%v]", a.configPath, err)
|
||||
if cc.Exists(am.configPath) {
|
||||
if err := conf.Load(&am.config, am.configPath); nil != err {
|
||||
return fmt.Errorf("Auth: Loading of NoAuth config file[%s] failed error[%v]", am.configPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
if nil != a.config.DenyDate {
|
||||
return fmt.Errorf("Cannot start because this probe have been denied from overFlow at %s", a.config.DenyDate.String())
|
||||
if nil != am.config.DenyDate {
|
||||
return fmt.Errorf("Cannot start because this probe have been denied from overFlow at %s", am.config.DenyDate.String())
|
||||
}
|
||||
|
||||
a.serviceDoneChan = make(chan error, 1)
|
||||
am.serviceDoneChan = make(chan error, 1)
|
||||
|
||||
rpcRegistry := crr.NewRPCRegistry()
|
||||
|
||||
napService := &oopar.NoAuthProbeService{
|
||||
DoneChan: a.serviceDoneChan,
|
||||
ConfigPath: a.configPath,
|
||||
Config: a.config,
|
||||
napService := &oopas.NoAuthProbeService{
|
||||
DoneChan: am.serviceDoneChan,
|
||||
ConfigPath: am.configPath,
|
||||
Config: am.config,
|
||||
}
|
||||
rpcRegistry.RegisterService(napService, "")
|
||||
|
||||
|
@ -74,52 +74,52 @@ func (a *auth) EndableStart(doneChan chan<- error) error {
|
|||
if nil == sb {
|
||||
return fmt.Errorf("Auth: Cannot create SocketBuilder")
|
||||
}
|
||||
a.cClient = client.NewClient(ch, sb)
|
||||
am.cClient = client.NewClient(ch, sb)
|
||||
|
||||
a.doneChan = doneChan
|
||||
a.stopChan = make(chan struct{})
|
||||
am.doneChan = doneChan
|
||||
am.stopChan = make(chan struct{})
|
||||
|
||||
a.stopWg.Add(1)
|
||||
go a.handleAuth()
|
||||
am.stopWg.Add(1)
|
||||
go am.handleAuth()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *auth) Stop() {
|
||||
a.destroy(nil)
|
||||
func (am *authManagers) Stop() {
|
||||
am.destroy(nil)
|
||||
}
|
||||
|
||||
func (a *auth) destroy(err error) {
|
||||
if a.stopChan == nil {
|
||||
func (am *authManagers) destroy(err error) {
|
||||
if am.stopChan == nil {
|
||||
logging.Logger().Warn("Auth: auth must be started before stopping it")
|
||||
}
|
||||
close(a.stopChan)
|
||||
a.stopWg.Wait()
|
||||
a.stopChan = nil
|
||||
close(am.stopChan)
|
||||
am.stopWg.Wait()
|
||||
am.stopChan = nil
|
||||
|
||||
a.cClient.Close()
|
||||
close(a.serviceDoneChan)
|
||||
am.cClient.Close()
|
||||
close(am.serviceDoneChan)
|
||||
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: stopped"))
|
||||
a.doneChan <- err
|
||||
am.doneChan <- err
|
||||
}
|
||||
|
||||
func (a *auth) handleAuth() {
|
||||
func (am *authManagers) handleAuth() {
|
||||
var err error
|
||||
defer func() {
|
||||
a.stopWg.Done()
|
||||
a.destroy(err)
|
||||
am.stopWg.Done()
|
||||
am.destroy(err)
|
||||
}()
|
||||
|
||||
if err = a.cClient.Connect(); nil != err {
|
||||
if err = am.cClient.Connect(); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case err = <-a.serviceDoneChan:
|
||||
case err = <-am.serviceDoneChan:
|
||||
return
|
||||
case <-a.stopChan:
|
||||
case <-am.stopChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import (
|
|||
"git.loafle.net/commons_go/logging"
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
)
|
||||
|
||||
func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
func NewSocketBuilder(napService *oopas.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
|
|||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
|
||||
napService *oopar.NoAuthProbeService
|
||||
napService *oopas.NoAuthProbeService
|
||||
}
|
||||
|
||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
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"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
||||
)
|
||||
|
||||
type SocketHandlers struct {
|
||||
cwfc.SocketHandlers
|
||||
|
||||
napService *oopar.NoAuthProbeService
|
||||
napService *oopas.NoAuthProbeService
|
||||
}
|
||||
|
||||
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
||||
|
@ -34,7 +34,7 @@ func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
|||
|
||||
}
|
||||
|
||||
func newSocketHandler(napService *oopar.NoAuthProbeService) cwfc.SocketHandler {
|
||||
func newSocketHandler(napService *oopas.NoAuthProbeService) cwfc.SocketHandler {
|
||||
return &SocketHandlers{
|
||||
napService: napService,
|
||||
}
|
||||
|
|
19
auth/rpc.go
19
auth/rpc.go
|
@ -1,19 +0,0 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
crr "git.loafle.net/commons_go/rpc/registry"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
)
|
||||
|
||||
func initRPCRegistry(a *auth) crr.RPCInvoker {
|
||||
rpcRegistry := crr.NewRPCRegistry()
|
||||
|
||||
napService := &oopar.NoAuthProbeService{
|
||||
DoneChan: a.serviceDoneChan,
|
||||
ConfigPath: a.configPath,
|
||||
Config: a.config,
|
||||
}
|
||||
rpcRegistry.RegisterService(napService, "")
|
||||
|
||||
return rpcRegistry
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package rpc
|
|
@ -1,4 +1,4 @@
|
|||
package client
|
||||
package data
|
||||
|
||||
import (
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
@ -1,4 +1,4 @@
|
|||
package client
|
||||
package data
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package client
|
||||
package data
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package client
|
||||
package data
|
||||
|
||||
import (
|
||||
"fmt"
|
11
client/file/client.go
Normal file
11
client/file/client.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
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)
|
||||
}
|
31
client/file/client_handlers.go
Normal file
31
client/file/client_handlers.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
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"))
|
||||
}
|
51
client/file/socket_builders.go
Normal file
51
client/file/socket_builders.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
)
|
||||
|
||||
func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
||||
return sb
|
||||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
|
||||
napService *oopar.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")
|
||||
}
|
||||
}
|
41
client/file/socket_handlers.go
Normal file
41
client/file/socket_handlers.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
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"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
)
|
||||
|
||||
type SocketHandlers struct {
|
||||
cwfc.SocketHandlers
|
||||
|
||||
napService *oopar.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 *oopar.NoAuthProbeService) cwfc.SocketHandler {
|
||||
return &SocketHandlers{
|
||||
napService: napService,
|
||||
}
|
||||
}
|
11
client/probe/client.go
Normal file
11
client/probe/client.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
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)
|
||||
}
|
31
client/probe/client_handlers.go
Normal file
31
client/probe/client_handlers.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package probe
|
||||
|
||||
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"))
|
||||
}
|
51
client/probe/socket_builders.go
Normal file
51
client/probe/socket_builders.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
)
|
||||
|
||||
func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
||||
return sb
|
||||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
|
||||
napService *oopar.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")
|
||||
}
|
||||
}
|
41
client/probe/socket_handlers.go
Normal file
41
client/probe/socket_handlers.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
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"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
)
|
||||
|
||||
type SocketHandlers struct {
|
||||
cwfc.SocketHandlers
|
||||
|
||||
napService *oopar.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 *oopar.NoAuthProbeService) cwfc.SocketHandler {
|
||||
return &SocketHandlers{
|
||||
napService: napService,
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package collector
|
||||
|
||||
type Collector interface {
|
||||
StartSensor() error
|
||||
StopSensor() error
|
||||
AddSensor() error
|
||||
RemoveSensor() error
|
||||
UpdateSensor() error
|
||||
}
|
||||
|
||||
type collector struct {
|
||||
}
|
||||
|
||||
func New() (Collector, error) {
|
||||
|
||||
c := &collector{}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *collector) StartSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) StopSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) AddSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) RemoveSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) UpdateSensor() error {
|
||||
return nil
|
||||
}
|
|
@ -1 +1,90 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
crr "git.loafle.net/commons_go/rpc/registry"
|
||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||
)
|
||||
|
||||
func New() ProbeManager {
|
||||
a := &probeManagers{}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
type ProbeManager interface {
|
||||
Start() error
|
||||
Stop()
|
||||
}
|
||||
|
||||
type probeManagers struct {
|
||||
cClient oogwc.Client
|
||||
|
||||
stopChan chan struct{}
|
||||
stopWg sync.WaitGroup
|
||||
}
|
||||
|
||||
func (pm *probeManagers) Start() error {
|
||||
if nil != pm.stopChan {
|
||||
logging.Logger().Panic("Probe: already running. Stop it before starting it again")
|
||||
}
|
||||
|
||||
rpcRegistry := crr.NewRPCRegistry()
|
||||
|
||||
// napService := &oopar.NoAuthProbeService{
|
||||
// DoneChan: pm.serviceDoneChan,
|
||||
// ConfigPath: pm.configPath,
|
||||
// Config: pm.config,
|
||||
// }
|
||||
// rpcRegistry.RegisterService(napService, "")
|
||||
|
||||
// ch := client.NewClientHandler(rpcRegistry)
|
||||
// sb := client.NewSocketBuilder(napService)
|
||||
// if nil == sb {
|
||||
// return fmt.Errorf("Auth: Cannot create SocketBuilder")
|
||||
// }
|
||||
// pm.cClient = client.NewClient(ch, sb)
|
||||
|
||||
pm.stopChan = make(chan struct{})
|
||||
|
||||
pm.stopWg.Add(1)
|
||||
go pm.handleProbe()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pm *probeManagers) Stop() {
|
||||
if pm.stopChan == nil {
|
||||
logging.Logger().Warn("Auth: auth must be started before stopping it")
|
||||
}
|
||||
close(pm.stopChan)
|
||||
pm.stopWg.Wait()
|
||||
pm.stopChan = nil
|
||||
|
||||
pm.cClient.Close()
|
||||
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: stopped"))
|
||||
|
||||
}
|
||||
|
||||
func (pm *probeManagers) handleProbe() {
|
||||
var err error
|
||||
defer func() {
|
||||
pm.stopWg.Done()
|
||||
pm.Stop()
|
||||
}()
|
||||
|
||||
if err = pm.cClient.Connect(); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-pm.stopChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
service/CrawlerService.go
Normal file
1
service/CrawlerService.go
Normal file
|
@ -0,0 +1 @@
|
|||
package service
|
2
service/ProbeService.go
Normal file
2
service/ProbeService.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package service
|
||||
|
4
service/SensorService.go
Normal file
4
service/SensorService.go
Normal file
|
@ -0,0 +1,4 @@
|
|||
package service
|
||||
|
||||
type SensorService struct {
|
||||
}
|
Loading…
Reference in New Issue
Block a user