mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Add id to service struct
This commit is contained in:
parent
43f87b9b57
commit
d2dc3b4cb6
1 changed files with 25 additions and 1 deletions
|
|
@ -1,17 +1,21 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"pilosa/config"
|
||||
"pilosa/db"
|
||||
"pilosa/interfaces"
|
||||
"syscall"
|
||||
"github.com/nu7hatch/gouuid"
|
||||
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Stopper
|
||||
Id *uuid.UUID
|
||||
Etcd *etcd.Client
|
||||
Cluster *db.Cluster
|
||||
TopologyMapper *TopologyMapper
|
||||
|
|
@ -23,6 +27,7 @@ type Service struct {
|
|||
|
||||
func NewService() *Service {
|
||||
service := new(Service)
|
||||
service.init_id()
|
||||
service.Etcd = etcd.NewClient(nil)
|
||||
service.Cluster = db.NewCluster()
|
||||
service.TopologyMapper = &TopologyMapper{service, "/pilosa/0"}
|
||||
|
|
@ -30,6 +35,25 @@ func NewService() *Service {
|
|||
return service
|
||||
}
|
||||
|
||||
func (service *Service) init_id() {
|
||||
var id *uuid.UUID
|
||||
var err error
|
||||
id_string := config.GetString("id")
|
||||
if id_string == "" {
|
||||
log.Println("Service id not configured, generating...")
|
||||
id, err = uuid.NewV4()
|
||||
if err != nil {
|
||||
log.Fatal("problem generating uuid")
|
||||
}
|
||||
} else {
|
||||
id, err = uuid.ParseHex(id_string)
|
||||
if err != nil {
|
||||
log.Fatalf("Service id '%s' not valid", id_string)
|
||||
}
|
||||
}
|
||||
service.Id = id
|
||||
}
|
||||
|
||||
func (service *Service) GetSignals() (chan os.Signal, chan os.Signal) {
|
||||
hupChan := make(chan os.Signal, 1)
|
||||
termChan := make(chan os.Signal, 1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue