ing
This commit is contained in:
parent
caaed69010
commit
fa3eb473fb
|
@ -72,10 +72,6 @@ func (a *auth) EndableStart(endded chan<- error) error {
|
|||
}
|
||||
|
||||
func (a *auth) start() error {
|
||||
if nil != config.CFG.Probe.Key || "" != *config.CFG.Probe.Key {
|
||||
return nil
|
||||
}
|
||||
|
||||
if nil != a.noAuthConfig.DenyDate {
|
||||
return fmt.Errorf("Cannot start because this probe have been denied from overFlow at %s", a.noAuthConfig.DenyDate.String())
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package collector
|
||||
|
||||
type Collector interface {
|
||||
StartSensor() error
|
||||
StopSensor() error
|
||||
AddSensor() error
|
||||
RemoveSensor() error
|
||||
UpdateSensor() error
|
||||
}
|
||||
|
||||
type collector struct {
|
||||
|
@ -13,18 +18,18 @@ func New() (Collector, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
func (c *collector) Start() error {
|
||||
func (c *collector) StartSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) Stop() error {
|
||||
func (c *collector) StopSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) Add() error {
|
||||
func (c *collector) AddSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) Remove() error {
|
||||
func (c *collector) RemoveSensor() error {
|
||||
return nil
|
||||
}
|
||||
func (c *collector) Update() error {
|
||||
func (c *collector) UpdateSensor() error {
|
||||
return nil
|
||||
}
|
||||
|
|
20
config.json
20
config.json
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"central": {
|
||||
"url": "ws://127.0.0.1:19190",
|
||||
"apikey": "52abd6fd57e511e7ac52080027658d13",
|
||||
"readBufferSize": 8192,
|
||||
"writeBufferSize": 8192
|
||||
},
|
||||
"probe": {
|
||||
"key": ""
|
||||
}
|
||||
}
|
||||
"central": {
|
||||
"url": "ws://127.0.0.1:19190",
|
||||
"apiKey": "52abd6fd57e511e7ac52080027658d13",
|
||||
"readBufferSize": 8192,
|
||||
"writeBufferSize": 8192
|
||||
},
|
||||
"probe": {
|
||||
"key": "52abd6fd57e511e7ac52080027658d13"
|
||||
}
|
||||
}
|
29
main.go
29
main.go
|
@ -78,21 +78,22 @@ func main() {
|
|||
}
|
||||
|
||||
go func() {
|
||||
if instance, err = auth.New(); nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Auth error: %v", err))
|
||||
return
|
||||
if nil == config.CFG.Probe.Key || "" == *config.CFG.Probe.Key {
|
||||
if instance, err = auth.New(); nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Auth error: %v", err))
|
||||
return
|
||||
}
|
||||
endded := make(chan error)
|
||||
defer close(endded)
|
||||
if err := instance.(commons.EndableStarter).EndableStart(endded); err != nil {
|
||||
logging.Logger.Error(fmt.Sprintf("Auther error: %v", err))
|
||||
return
|
||||
}
|
||||
if err := <-endded; nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Auther error: %v", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
endded := make(chan error)
|
||||
defer close(endded)
|
||||
if err := instance.(commons.EndableStarter).EndableStart(endded); err != nil {
|
||||
logging.Logger.Error(fmt.Sprintf("Auther error: %v", err))
|
||||
return
|
||||
}
|
||||
if err := <-endded; nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Auther error: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
if instance, err = probe.New(); nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Probe error: %v", err))
|
||||
return
|
||||
|
|
3
noauthprobe.json
Normal file
3
noauthprobe.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"tempKey": "aecae27c-11ef-4c0b-b3ee-d711681b2e8c"
|
||||
}
|
|
@ -98,9 +98,9 @@ func (p *probe) connectToCentral() error {
|
|||
|
||||
p.probeClient.OnNotify(p.onNotify)
|
||||
|
||||
if _, err = client.ConnectToCentralAsProbe(p.metricClient, p.metricEntryURL); nil != err {
|
||||
return err
|
||||
}
|
||||
// if _, err = client.ConnectToCentralAsProbe(p.metricClient, p.metricEntryURL); nil != err {
|
||||
// return err
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -123,4 +123,10 @@ func (p *probe) Shutdown(ctx context.Context) error {
|
|||
|
||||
func (p *probe) stop(err error) {
|
||||
defer close(p.shutdown)
|
||||
|
||||
ctx := context.Background()
|
||||
if err := p.probeClient.Shutdown(ctx); nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Client of Probe: %v", err))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user