Initialize template maps in server options

This commit is contained in:
Raul Ochoa 2015-01-30 15:30:13 +01:00
parent aecb07b008
commit e28fe1fdc0
2 changed files with 25 additions and 22 deletions

View File

@ -1,11 +1,9 @@
var _ = require('underscore')
, Step = require('step')
, Windshaft = require('windshaft')
, TemplateMaps = require('./template_maps.js')
, Cache = require('./cache_validator')
, os = require('os')
, HealthCheck = require('./monitoring/health_check')
;
var _ = require('underscore');
var Step = require('step');
var Windshaft = require('windshaft');
var Cache = require('./cache_validator');
var os = require('os');
var HealthCheck = require('./monitoring/health_check');
if ( ! process.env['PGAPPNAME'] )
process.env['PGAPPNAME']='cartodb_tiler';
@ -48,12 +46,6 @@ var CartodbWindshaft = function(serverOptions) {
//
var template_baseurl = global.environment.base_url_templated || '(?:/maps/named|/tiles/template)';
var templateMapsOpts = {
max_user_templates: global.environment.maxUserTemplates
};
var templateMaps = new TemplateMaps(redisPool, templateMapsOpts);
serverOptions.templateMaps = templateMaps;
var SurrogateKeysCache = require('./cache/surrogate_keys_cache'),
NamedMapsCacheEntry = require('./cache/model/named_maps_entry'),
VarnishHttpCacheBackend = require('./cache/backend/varnish_http'),
@ -158,7 +150,13 @@ var CartodbWindshaft = function(serverOptions) {
var TemplateMapsController = require('./controllers/template_maps'),
templateMapsController = new TemplateMapsController(
ws, serverOptions, templateMaps, cartoData, template_baseurl, surrogateKeysCache, NamedMapsCacheEntry
ws,
serverOptions,
serverOptions.templateMaps,
cartoData,
template_baseurl,
surrogateKeysCache,
NamedMapsCacheEntry
);
templateMapsController.register(ws);

View File

@ -1,10 +1,10 @@
var _ = require('underscore')
, Step = require('step')
, Cache = require('./cache_validator')
, QueryTablesApi = require('./api/query_tables_api')
, crypto = require('crypto')
, LZMA = require('lzma').LZMA
;
var _ = require('underscore');
var Step = require('step');
var Cache = require('./cache_validator');
var QueryTablesApi = require('./api/query_tables_api');
var crypto = require('crypto');
var LZMA = require('lzma').LZMA;
var TemplateMaps = require('./template_maps.js');
// This is for backward compatibility with 1.3.3
if ( _.isUndefined(global.environment.sqlapi.domain) ) {
@ -106,6 +106,11 @@ module.exports = function(redisPool) {
// Re-use redisPool
me.redis.pool = redisPool;
var templateMaps = new TemplateMaps(redisPool, {
max_user_templates: global.environment.maxUserTemplates
});
me.templateMaps = templateMaps;
/* This whole block is about generating X-Cache-Channel { */
// TODO: review lifetime of elements of this cache