remove Cruncher() struct. Use Service() instead

This commit is contained in:
travisturner 2013-12-09 15:21:17 -06:00
parent 40e7474d82
commit fc2ea849c3
3 changed files with 42 additions and 59 deletions

View file

@ -1,7 +1,7 @@
package main
import (
"pilosa/cruncher"
"pilosa/core"
"pilosa/db"
"flag"
"log"
@ -26,6 +26,6 @@ func main() {
log.Fatal("Location not valid:", httpLoc)
}
cruncher := cruncher.NewCruncher(tcp, http)
cruncher.Run()
service := core.NewService(tcp, http)
service.Run()
}

View file

@ -290,3 +290,42 @@ func (service *Service) NewListener() chan *db.Message {
ch := make(chan *db.Message)
return ch
}
////////////////////////////////////////////////
func (service *Service) Run() {
log.Println("Running service...")
service.SetupEtcd()
//go r.SyncEtcd()
//go service.WatchEtcd()
//go service.HandleConnections()
//service.SetupNetwork()
//go service.Serve()
//go service.HandleInbox()
//go service.ServeHTTP()
go service.MetaWatcher()
sigterm, sighup := service.GetSignals()
for {
select {
case <- sighup:
log.Println("SIGHUP! Reloading configuration...")
// TODO: reload configuration
case <- sigterm:
log.Println("SIGTERM! Cleaning up...")
service.Stop()
return
}
}
}
func (service *Service) HandleInbox() {
for {
select {
case message := <-service.Inbox:
log.Println("process", message)
}
}
}

View file

@ -1,56 +0,0 @@
package cruncher
import (
"pilosa/core"
"pilosa/db"
"log"
)
type Cruncher struct {
core.Service
}
func (c *Cruncher) Init() {
log.Println("Initializing cruncher...")
}
func (c *Cruncher) Run() {
log.Println("Running cruncher...")
c.SetupEtcd()
//go r.SyncEtcd()
//go c.WatchEtcd()
//go c.HandleConnections()
//c.SetupNetwork()
//go c.Serve()
//go c.HandleInbox()
//go c.ServeHTTP()
go c.MetaWatcher()
sigterm, sighup := c.GetSignals()
for {
select {
case <- sighup:
log.Println("SIGHUP! Reloading configuration...")
// TODO: reload configuration
case <- sigterm:
log.Println("SIGTERM! Cleaning up...")
c.Stop()
return
}
}
}
func NewCruncher(tcp, http *db.Location) *Cruncher {
service := core.NewService(tcp, http)
cruncher := Cruncher{*service}
return &cruncher
}
func (c *Cruncher) HandleInbox() {
for {
select {
case message := <-c.Inbox:
log.Println("process", message)
}
}
}