new logic

This commit is contained in:
insanity@loafle.com 2017-05-15 13:57:38 +09:00
parent 72e5387a51
commit 35fa492fd5

118
agent.go
View File

@ -1,44 +1,106 @@
package main
import (
"loafle.com/overflow/agent_api/observer"
"loafle.com/overflow/agent_api/observer/messages"
_ "loafle.com/overflow/config_manager_go"
_ "loafle.com/overflow/crawler_manager_go"
_ "loafle.com/overflow/collector_go"
_ "loafle.com/overflow/data_sender_go"
_ "loafle.com/overflow/event_sender"
_ "loafle.com/overflow/long_poller_go"
"time"
"sync"
//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"
"log"
"loafle.com/overflow/agent_api/observer/messages"
cm "loafle.com/overflow/agent_api/config_manager"
)
func main() {
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)
observer.Notify(messages.AGT_INITIALIZED, "")
wg := sync.WaitGroup{}
wg.Add(1)
wg.Wait()
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() {
//
}