1
0

Add prometheus endpoint for getting metrics (#33)

This commit is contained in:
konrad
2018-12-12 22:50:35 +00:00
committed by Gitea
parent ee398b5272
commit e047673c6b
189 changed files with 44128 additions and 94 deletions

View File

@ -17,14 +17,13 @@
package models
import (
"encoding/gob"
"fmt"
_ "github.com/go-sql-driver/mysql" // Because.
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
xrc "github.com/go-xorm/xorm-redis-cache"
_ "github.com/mattn/go-sqlite3" // Because.
"encoding/gob"
"github.com/spf13/viper"
)
@ -86,7 +85,7 @@ func SetEngine() (err error) {
x.SetDefaultCacher(cacher)
break
case "redis":
cacher := xrc.NewRedisCacher(viper.GetString("cache.redishost"), viper.GetString("cache.redispassword"), xrc.DEFAULT_EXPIRATION, x.Logger())
cacher := xrc.NewRedisCacher(viper.GetString("redis.host"), viper.GetString("redis.password"), xrc.DEFAULT_EXPIRATION, x.Logger())
x.SetDefaultCacher(cacher)
gob.Register(tables)
break
@ -118,3 +117,8 @@ func getLimitFromPageIndex(page int) (limit, start int) {
start = limit * (page - 1)
return
}
// GetTotalCount returns the total amount of something
func GetTotalCount(counting interface{}) (count int64, err error) {
return x.Count(counting)
}