ing
This commit is contained in:
parent
cf4820d89b
commit
e6f66ad7f0
10
auth/auth.go
10
auth/auth.go
|
@ -1,6 +1,7 @@
|
||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -9,6 +10,7 @@ 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"
|
||||||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
||||||
|
oocmci "git.loafle.net/overflow/overflow_commons_go/modules/commons/interfaces"
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
"git.loafle.net/overflow/overflow_probes/auth/client"
|
"git.loafle.net/overflow/overflow_probes/auth/client"
|
||||||
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
|
||||||
|
@ -22,8 +24,8 @@ func New() AuthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthManager interface {
|
type AuthManager interface {
|
||||||
EndableStart(doneChan chan<- error) error
|
oocmci.EndableStarter
|
||||||
Stop()
|
oocmci.Stopper
|
||||||
}
|
}
|
||||||
|
|
||||||
type authManagers struct {
|
type authManagers struct {
|
||||||
|
@ -85,8 +87,10 @@ func (am *authManagers) EndableStart(doneChan chan<- error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (am *authManagers) Stop() {
|
func (am *authManagers) Stop(ctx context.Context) error {
|
||||||
am.destroy(nil)
|
am.destroy(nil)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (am *authManagers) destroy(err error) {
|
func (am *authManagers) destroy(err error) {
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package commons
|
|
||||||
|
|
||||||
type EndableStarter interface {
|
|
||||||
EndableStart(endded chan<- error) error
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package commons
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
type Shutdowner interface {
|
|
||||||
Shutdown(ctx context.Context) error
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package commons
|
|
||||||
|
|
||||||
type Starter interface {
|
|
||||||
Start() error
|
|
||||||
}
|
|
8
main.go
8
main.go
|
@ -14,8 +14,8 @@ import (
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
oocc "git.loafle.net/overflow/overflow_commons_go/config"
|
oocc "git.loafle.net/overflow/overflow_commons_go/config"
|
||||||
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
|
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
|
||||||
|
oocmci "git.loafle.net/overflow/overflow_commons_go/modules/commons/interfaces"
|
||||||
"git.loafle.net/overflow/overflow_probes/auth"
|
"git.loafle.net/overflow/overflow_probes/auth"
|
||||||
"git.loafle.net/overflow/overflow_probes/commons"
|
|
||||||
"git.loafle.net/overflow/overflow_probes/config"
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
"git.loafle.net/overflow/overflow_probes/probe"
|
"git.loafle.net/overflow/overflow_probes/probe"
|
||||||
)
|
)
|
||||||
|
@ -71,7 +71,7 @@ func main() {
|
||||||
authDoneChan := make(chan error, 1)
|
authDoneChan := make(chan error, 1)
|
||||||
defer close(authDoneChan)
|
defer close(authDoneChan)
|
||||||
|
|
||||||
if err := instance.(commons.EndableStarter).EndableStart(authDoneChan); err != nil {
|
if err := instance.(oocmci.EndableStarter).EndableStart(authDoneChan); err != nil {
|
||||||
logging.Logger().Error(err)
|
logging.Logger().Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instance = probe.New()
|
instance = probe.New()
|
||||||
if err := instance.(commons.Starter).Start(); err != nil {
|
if err := instance.(oocmci.Starter).Start(); err != nil {
|
||||||
logging.Logger().Error(err)
|
logging.Logger().Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func main() {
|
||||||
<-interrupt
|
<-interrupt
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := instance.(commons.Shutdowner).Shutdown(ctx); err != nil {
|
if err := instance.(oocmci.Stopper).Stop(ctx); err != nil {
|
||||||
logging.Logger().Errorf("Probe error: %v", err)
|
logging.Logger().Errorf("Probe error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package probe
|
package probe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
cdr "git.loafle.net/commons_go/di/registry"
|
cdr "git.loafle.net/commons_go/di/registry"
|
||||||
"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"
|
||||||
|
oocmci "git.loafle.net/overflow/overflow_commons_go/modules/commons/interfaces"
|
||||||
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
oopccd "git.loafle.net/overflow/overflow_probes/client/central/data"
|
oopccd "git.loafle.net/overflow/overflow_probes/client/central/data"
|
||||||
|
@ -21,8 +23,8 @@ func New() ProbeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProbeManager interface {
|
type ProbeManager interface {
|
||||||
Start() error
|
oocmci.Starter
|
||||||
Stop()
|
oocmci.Stopper
|
||||||
}
|
}
|
||||||
|
|
||||||
type probeManagers struct {
|
type probeManagers struct {
|
||||||
|
@ -78,7 +80,7 @@ func (pm *probeManagers) Start() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *probeManagers) Stop() {
|
func (pm *probeManagers) Stop(ctx context.Context) error {
|
||||||
if pm.stopChan == nil {
|
if pm.stopChan == nil {
|
||||||
logging.Logger().Warnf("Probe: probe must be started before stopping it")
|
logging.Logger().Warnf("Probe: probe must be started before stopping it")
|
||||||
}
|
}
|
||||||
|
@ -90,13 +92,14 @@ func (pm *probeManagers) Stop() {
|
||||||
|
|
||||||
logging.Logger().Infof("Probe: stopped")
|
logging.Logger().Infof("Probe: stopped")
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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(nil)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// if err = pm.cClient.Connect(); nil != err {
|
// if err = pm.cClient.Connect(); nil != err {
|
||||||
|
|
|
@ -3,6 +3,12 @@ package service
|
||||||
func InitService() {
|
func InitService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StartService() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func StopService() {
|
||||||
|
}
|
||||||
|
|
||||||
func DestroyService() {
|
func DestroyService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user