agent/agent.go

106 lines
2.3 KiB
Go
Raw Normal View History

2017-05-11 09:39:01 +00:00
package main
import (
2017-05-15 04:57:38 +00:00
//crm "loafle.com/overflow/crawler_manager_go"
//col "loafle.com/overflow/collector_go"
//dat "loafle.com/overflow/data_sender_go"
//evt "loafle.com/overflow/event_sender_go"
pol "loafle.com/overflow/long_poller_go"
2017-05-11 10:29:32 +00:00
"log"
2017-05-15 04:57:38 +00:00
"loafle.com/overflow/agent_api/observer/messages"
cm "loafle.com/overflow/agent_api/config_manager"
2017-05-11 09:39:01 +00:00
)
func main() {
2017-05-11 10:29:32 +00:00
log.SetPrefix("Agent : ")
2017-05-15 04:57:38 +00:00
agt := &Agent{}
agt.start()
}
type Agent struct {
taskCh chan string
conf *cm.ConfigManager
}
func (agt *Agent) start() {
agt.startAgent()
}
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
go agt.waitTask()
2017-05-11 09:39:01 +00:00
}
2017-05-15 04:57:38 +00:00
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:
}
}
}
2017-05-11 09:39:01 +00:00
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
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)
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessStartSensor() {
//col startSensor() -> evt result
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessstopSensor() {
//col stopSensor() -> evt result
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessAddSensor() {
//scm addSensor() (id chan string, error)
//crm addSensor() (id chan string, error)
//col addSensor() -> evt result
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessRemoveSensor() {
//col removeSensor() (id chan string, error)
//crm removeSensor() (id chan string, error)
//scm removeSensor() -> evt result
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
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
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessUpdateCRM() {
//(loop)col stopSensor() (chan []string?, error)
//crm updateCRM()
//(loop)col startSensor() -> evt result
}
2017-05-11 10:29:32 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessUpdateAgent() {
//
}
2017-05-11 09:39:01 +00:00
2017-05-15 04:57:38 +00:00
func (agt *Agent) ProcessSendLog() {
//
2017-05-11 09:39:01 +00:00
}