new logic
This commit is contained in:
parent
72e5387a51
commit
35fa492fd5
118
agent.go
118
agent.go
|
@ -1,44 +1,106 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"loafle.com/overflow/agent_api/observer"
|
//crm "loafle.com/overflow/crawler_manager_go"
|
||||||
"loafle.com/overflow/agent_api/observer/messages"
|
//col "loafle.com/overflow/collector_go"
|
||||||
_ "loafle.com/overflow/config_manager_go"
|
//dat "loafle.com/overflow/data_sender_go"
|
||||||
_ "loafle.com/overflow/crawler_manager_go"
|
//evt "loafle.com/overflow/event_sender_go"
|
||||||
_ "loafle.com/overflow/collector_go"
|
pol "loafle.com/overflow/long_poller_go"
|
||||||
_ "loafle.com/overflow/data_sender_go"
|
|
||||||
_ "loafle.com/overflow/event_sender"
|
|
||||||
_ "loafle.com/overflow/long_poller_go"
|
|
||||||
"time"
|
|
||||||
"sync"
|
|
||||||
"log"
|
"log"
|
||||||
|
"loafle.com/overflow/agent_api/observer/messages"
|
||||||
|
cm "loafle.com/overflow/agent_api/config_manager"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
log.SetPrefix("Agent : ")
|
log.SetPrefix("Agent : ")
|
||||||
initAgent()
|
agt := &Agent{}
|
||||||
|
agt.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initAgent() {
|
type Agent struct {
|
||||||
|
taskCh chan string
|
||||||
|
conf *cm.ConfigManager
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("initAgent")
|
func (agt *Agent) start() {
|
||||||
|
agt.startAgent()
|
||||||
|
}
|
||||||
|
|
||||||
observer.Notify(messages.AGT_STARTING, "/home/snoop/develop/path/go/src/loafle.com/overflow/config_manager_go/test_agent/")
|
func (agt *Agent) startAgent() {
|
||||||
|
//cfg start() (chan bool, error)
|
||||||
|
//evt start() (chan bool, error)
|
||||||
|
//dat start() (chan bool, error)
|
||||||
|
//pol start() (chan string, error) -> getting an Auth key from API server and store that key.
|
||||||
|
agt.taskCh = pol.Start()
|
||||||
|
//scm start() with the Auth key (chan bool, error)
|
||||||
|
//crm start() (chan bool, error)
|
||||||
|
//col start() -> evt result
|
||||||
|
|
||||||
log.Println("AGT_STARTING after")
|
go agt.waitTask()
|
||||||
|
}
|
||||||
|
|
||||||
time.Sleep(time.Second * 2)
|
func (agt *Agent)waitTask() {
|
||||||
|
for {
|
||||||
observer.Notify(messages.AGT_INITIALIZED, "")
|
task := <- agt.taskCh
|
||||||
|
switch task {
|
||||||
wg := sync.WaitGroup{}
|
case messages.AGT_WILL_STOP:
|
||||||
|
agt.stopAgent()
|
||||||
wg.Add(1)
|
break;
|
||||||
|
case messages.TASK_SENSOR_START:
|
||||||
|
break;
|
||||||
wg.Wait()
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (agt *Agent) stopAgent() {
|
||||||
|
//col stop() (chan bool, error)
|
||||||
|
//crm stop() (chan bool, error)
|
||||||
|
//scm stop() (chan bool, error)
|
||||||
|
//dat stop() (chan bool, error)
|
||||||
|
//pol stop() (chan bool, error)
|
||||||
|
//evt stop() -> evt result (before stop)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessStartSensor() {
|
||||||
|
//col startSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessstopSensor() {
|
||||||
|
//col stopSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessAddSensor() {
|
||||||
|
//scm addSensor() (id chan string, error)
|
||||||
|
//crm addSensor() (id chan string, error)
|
||||||
|
//col addSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessRemoveSensor() {
|
||||||
|
//col removeSensor() (id chan string, error)
|
||||||
|
//crm removeSensor() (id chan string, error)
|
||||||
|
//scm removeSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessUpdateSensor() {
|
||||||
|
//col stopSensor() (id chan string, error)
|
||||||
|
//scm updateSensor() (id chan string, error)
|
||||||
|
//crm updateSensor() (id chan string, error)
|
||||||
|
//col updateSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessUpdateCRM() {
|
||||||
|
//(loop)col stopSensor() (chan []string?, error)
|
||||||
|
//crm updateCRM()
|
||||||
|
//(loop)col startSensor() -> evt result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessUpdateAgent() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent) ProcessSendLog() {
|
||||||
|
//
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user