[WIP] migration to psql

TODO:
[ ] stats
[ ] indexes
This commit is contained in:
Las Zenow 2016-07-30 07:10:33 -04:00
parent e1bd235785
commit e72de38725
24 changed files with 648 additions and 936 deletions

View file

@ -56,18 +56,16 @@ func (sg StatsGatherer) Gather(function func(handler)) func(http.ResponseWriter,
return func(w http.ResponseWriter, r *http.Request) {
log.Info("Query ", r.Method, " ", r.RequestURI)
db := sg.db.Copy()
h := handler{
store: sg.store,
db: db,
db: sg.db,
template: sg.template,
hostname: sg.hostname,
w: w,
r: r,
sess: GetSession(r, db),
sess: GetSession(r, sg.db),
ro: sg.ro,
}
defer h.db.Close()
function(h)
sg.channel <- statsRequest{time.Now(), mux.Vars(r), h.sess, r}
@ -82,9 +80,6 @@ type statsRequest struct {
}
func (sg StatsGatherer) worker() {
db := sg.db.Copy()
defer db.Close()
for req := range sg.channel {
stats := make(map[string]interface{})
appendFiles(req.r, stats)
@ -94,7 +89,7 @@ func (sg StatsGatherer) worker() {
stats["version"] = stats_version
stats["method"] = req.r.Method
stats["date"] = req.date
db.AddStats(stats)
sg.db.AddStats(stats)
}
}