removed mongodb

This commit is contained in:
didier amyot committed 2014-12-27 18:29:24 -08:00
1 parent 8976b50cc5
commit f6ec518814
4 files changed
+3 -154

No files matched your search

+2 -34
View File
@@ -3,7 +3,6 @@ package main
import (
"io/ioutil"
mgo "gopkg.in/mgo.v2"
goyaml "gopkg.in/yaml.v2"
)
@@ -12,15 +11,9 @@ const PARAM_FILE string = "params.yml"
type Params struct {
Port int `yaml:"port,omitempty"`
Host string `yaml:"host,omitempty"`
Mongo *MongoParams `yaml:"mongo,omitempty"`
MongoClient *mgo.Session `yaml:"-"`
DB *mgo.Database `yaml:"-"`
}
type MongoParams struct {
Url string `yaml:"url,omitempty"`
DatabaseName string `yaml:"database_name,omitempty"`
}
func (this *Params) LoadFromYamlFile(fileName string) error {
data, err := ioutil.ReadFile(fileName)
@@ -43,36 +36,14 @@ func (this *Params) LoadFromYamlData(data []byte) error {
if p.Port > 0 {
this.Port = p.Port
}
if p.Mongo == nil {
return nil
}
if p.Mongo.Url != "" {
this.Mongo.Url = p.Mongo.Url
}
if p.Mongo.DatabaseName != "" {
this.Mongo.DatabaseName = p.Mongo.DatabaseName
}
if p.Mongo.DatabaseName != "" {
this.Mongo.DatabaseName = p.Mongo.DatabaseName
}
return nil
}
func (this *Params) initMongo() error {
var err error
this.MongoClient, err = mgo.Dial(this.Mongo.Url)
this.DB = this.MongoClient.DB(this.Mongo.DatabaseName)
return err
}
func GetDefaultParams() *Params {
mongoParams := &MongoParams{
Url: "localhost:27017",
DatabaseName: "union",
}
return &Params{7777, "localhost", mongoParams, nil, nil}
return &Params{7777, "localhost"}
}
var params = GetDefaultParams()
@@ -81,7 +52,4 @@ func init() {
if err := params.LoadFromYamlFile(PARAM_FILE); err != nil {
panic(err)
}
if err := params.initMongo(); err != nil {
panic(err)
}
}