Esempio n. 1
0
func NewFunServant(cf *config.ConfigServant) (this *FunServantImpl) {
	this = &FunServantImpl{
		conf:            cf,
		digitNormalizer: regexp.MustCompile(`\d+`),
		proxyMode:       config.Engine.IsProxyOnly(),
	}

	// http REST to export internal state
	server.RegisterHttpApi("/svt/{cmd}",
		func(w http.ResponseWriter, req *http.Request,
			params map[string]interface{}) (interface{}, error) {
			return this.handleHttpQuery(w, req, params)
		}).Methods("GET")

	this.sessions = cache.NewLruCache(cf.SessionMaxItems)
	this.mysqlMergeMutexMap = mutexmap.New(cf.Mysql.JsonMergeMaxOutstandingItems)

	this.ctxReasonPercentage = metrics.NewPercentCounter()
	metrics.Register("call.reason", this.ctxReasonPercentage)
	this.dbCacheHits = metrics.NewPercentCounter()
	metrics.Register("db.cache.hits", this.dbCacheHits)

	this.createServants()

	return
}
Esempio n. 2
0
func (this *servantStats) registerMetrics() {
	this.calls = metrics.NewPercentCounter()
	metrics.Register("servant.calls", this.calls)
}