|
|
|
@ -18,11 +18,11 @@ import (
|
|
|
|
|
|
|
|
|
|
type Manager interface {
|
|
|
|
|
Start() error // status checks
|
|
|
|
|
Exit() error
|
|
|
|
|
Stop() error
|
|
|
|
|
Timeout() (time.Duration, error) // TO Generator
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewManager(max int) Manager {
|
|
|
|
|
func NewManager(max int) (Manager, error) {
|
|
|
|
|
// takes a heartbeat and max connection attempts
|
|
|
|
|
return manager.New(max)
|
|
|
|
|
}
|
|
|
|
@ -37,30 +37,31 @@ type ReactorManager struct {
|
|
|
|
|
Err chan error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewReactorManager(cl *Client, config *viper.Viper, errCh chan error) *ReactorManager {
|
|
|
|
|
func NewReactorManager(cl *Client,
|
|
|
|
|
config *viper.Viper,
|
|
|
|
|
errCh chan error,
|
|
|
|
|
) (*ReactorManager, error) {
|
|
|
|
|
// making managers
|
|
|
|
|
m := NewManager(6)
|
|
|
|
|
m, err := NewManager(6)
|
|
|
|
|
r := &ReactorManager{
|
|
|
|
|
Manager: m,
|
|
|
|
|
Client: cl,
|
|
|
|
|
Config: config,
|
|
|
|
|
Err: errCh,
|
|
|
|
|
}
|
|
|
|
|
return r
|
|
|
|
|
return r, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ReactorManager) Start() error {
|
|
|
|
|
// allows for extra stuff
|
|
|
|
|
logging.Debug(logging.DStart, "RMA %v starting", r.Id)
|
|
|
|
|
return r.Manager.Start()
|
|
|
|
|
//go r.StatusMon.Send(&DeviceInfo{Id: r.Id, Type: "Reactor", Status: "[green]ONLINE[white]"}, "Reactor")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ReactorManager) Exit() error {
|
|
|
|
|
// allows for extra stuff
|
|
|
|
|
logging.Debug(logging.DExit, "RMA %v exiting", r.Id)
|
|
|
|
|
return r.Manager.Exit()
|
|
|
|
|
//go r.StatusMon.Send(&DeviceInfo{Id: r.Id, Type: "Reactor", Status: "[red]OFFLINE[white]", Data: fmt.Sprintf("Last Seen %v", time.Now().Format("Mon at 03:04:05pm MST"))}, "Reactor")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ReactorManager) UpdateClient(cl *Client) error {
|
|
|
|
@ -72,7 +73,6 @@ func (r *ReactorManager) UpdateClient(cl *Client) error {
|
|
|
|
|
|
|
|
|
|
func (r *ReactorManager) ReactorStatusHandler(ctx context.Context, req *pb.ReactorStatusPing) (*pb.ReactorStatusResponse, error) {
|
|
|
|
|
// function client will call to update reactor information
|
|
|
|
|
//go r.PingReset()
|
|
|
|
|
fmt.Printf("Recieved ping from %d!\n", req.GetId())
|
|
|
|
|
// update devices/sensors
|
|
|
|
|
for _, dev := range req.GetDevices() {
|
|
|
|
|