Exemplo n.º 1
0
package tilerender

import (
	"sync"
	"time"

	"gopnik"

	"github.com/orofarne/hmetrics2"
)

var hRenderTime = hmetrics2.MustRegisterPackageMetric("render_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hWaitTime = hmetrics2.MustRegisterPackageMetric("wait_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hhpQueueElems = hmetrics2.MustRegisterPackageMetric("hp_queue_elems", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hlpQueueElems = hmetrics2.MustRegisterPackageMetric("lp_queue_elems", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)

type renderWrapper struct {
	render  *TileRender
	hpTasks *renderQueue
	lpTasks *renderQueue
	cmd     []string
	ttl     uint
	ttlMu   sync.Mutex
	stop    chan int
}

func newRenderWrapper(hpTasks, lpTasks *renderQueue, cmd []string, ttl uint) (*renderWrapper, error) {
	self := new(renderWrapper)
	self.hpTasks = hpTasks
	self.lpTasks = lpTasks
	self.cmd = cmd
Exemplo n.º 2
0
	"fmt"
	"net/http"
	"strconv"
	"strings"
	"sync"
	"time"

	"gopnik"

	"github.com/op/go-logging"
	"github.com/orofarne/hmetrics2"
)

var log = logging.MustGetLogger("global")

var hReqT = hmetrics2.MustRegisterPackageMetric("request_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hCacheT = hmetrics2.MustRegisterPackageMetric("cache_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hRenderT = hmetrics2.MustRegisterPackageMetric("render_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hReq200 = hmetrics2.MustRegisterPackageMetric("code_200", hmetrics2.NewCounter()).(*hmetrics2.Counter)
var hReq400 = hmetrics2.MustRegisterPackageMetric("code_400", hmetrics2.NewCounter()).(*hmetrics2.Counter)
var hReq500 = hmetrics2.MustRegisterPackageMetric("code_500", hmetrics2.NewCounter()).(*hmetrics2.Counter)

type renderResponse struct {
	Error error
	Tile  []byte
}

type renderTask struct {
	gopnik.TileCoord
	ResultCh []chan renderResponse
}
Exemplo n.º 3
0
	"sync"
	"time"

	"github.com/op/go-logging"
	"github.com/orofarne/hmetrics2"

	"app"
	"gopnik"
	"gopnikrpc"
	"perflog"
	"tilerender"
)

var log = logging.MustGetLogger("global")

var hReqT = hmetrics2.MustRegisterPackageMetric("request_time", hmetrics2.NewHistogram()).(*hmetrics2.Histogram)
var hReqOk = hmetrics2.MustRegisterPackageMetric("request_ok", hmetrics2.NewCounter()).(*hmetrics2.Counter)
var hReqErr = hmetrics2.MustRegisterPackageMetric("request_err", hmetrics2.NewCounter()).(*hmetrics2.Counter)

type TileServer struct {
	renders     *tilerender.MultiRenderPool
	cache       gopnik.CachePluginInterface
	saveList    *list.List
	saveListMu  sync.RWMutex
	removeDelay time.Duration
}

type saveQueueElem struct {
	gopnik.TileCoord
	Data []gopnik.Tile
}