mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-09 07:26:48 +00:00
engine: GetSubsystemsStatus fix (#773)
* engine: GetSubsystemsStatus fix * engine: force map literal to stop doubling up on keys, expanded test coverage * engine: Deploy default for migration requirement. * glorious: nits addr * glorious: suggestion * tests: fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
// ConnectionManagerName is an exported subsystem name
|
||||
const ConnectionManagerName = "internet_monitor"
|
||||
|
||||
var errConnectionCheckerIsNil = errors.New("connection checker is nil")
|
||||
|
||||
// connectionManager manages the connchecker
|
||||
type connectionManager struct {
|
||||
started int32
|
||||
@@ -72,14 +75,17 @@ func (m *connectionManager) Start() error {
|
||||
// Stop stops the connection manager
|
||||
func (m *connectionManager) Stop() error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("connection manager %w", ErrNilSubsystem)
|
||||
return fmt.Errorf("connection manager: %w", ErrNilSubsystem)
|
||||
}
|
||||
if atomic.LoadInt32(&m.started) == 0 {
|
||||
return fmt.Errorf("connection manager %w", ErrSubSystemNotStarted)
|
||||
return fmt.Errorf("connection manager: %w", ErrSubSystemNotStarted)
|
||||
}
|
||||
defer func() {
|
||||
atomic.CompareAndSwapInt32(&m.started, 1, 0)
|
||||
}()
|
||||
if m.conn == nil {
|
||||
return fmt.Errorf("connection manager: %w", errConnectionCheckerIsNil)
|
||||
}
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager shutting down...")
|
||||
m.conn.Shutdown()
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager stopped.")
|
||||
|
||||
Reference in New Issue
Block a user