new logic
This commit is contained in:
parent
72e5387a51
commit
35fa492fd5
128
agent.go
128
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
|
||||||
log.Println("initAgent")
|
conf *cm.ConfigManager
|
||||||
|
}
|
||||||
observer.Notify(messages.AGT_STARTING, "/home/snoop/develop/path/go/src/loafle.com/overflow/config_manager_go/test_agent/")
|
|
||||||
|
func (agt *Agent) start() {
|
||||||
log.Println("AGT_STARTING after")
|
agt.startAgent()
|
||||||
|
}
|
||||||
time.Sleep(time.Second * 2)
|
|
||||||
|
func (agt *Agent) startAgent() {
|
||||||
observer.Notify(messages.AGT_INITIALIZED, "")
|
//cfg start() (chan bool, error)
|
||||||
|
//evt start() (chan bool, error)
|
||||||
wg := sync.WaitGroup{}
|
//dat start() (chan bool, error)
|
||||||
|
//pol start() (chan string, error) -> getting an Auth key from API server and store that key.
|
||||||
wg.Add(1)
|
agt.taskCh = pol.Start()
|
||||||
|
//scm start() with the Auth key (chan bool, error)
|
||||||
|
//crm start() (chan bool, error)
|
||||||
wg.Wait()
|
//col start() -> evt result
|
||||||
|
|
||||||
|
go agt.waitTask()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agt *Agent)waitTask() {
|
||||||
|
for {
|
||||||
|
task := <- agt.taskCh
|
||||||
|
switch task {
|
||||||
|
case messages.AGT_WILL_STOP:
|
||||||
|
agt.stopAgent()
|
||||||
|
break;
|
||||||
|
case messages.TASK_SENSOR_START:
|
||||||
|
break;
|
||||||
|
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