@cubejs-backend/query-orchestrator
Advanced tools
Comparing version 0.0.8 to 0.0.21
@@ -49,3 +49,3 @@ const crypto = require('crypto'); | ||
this.redisPrefix = redisPrefix; | ||
this.clientFactory = clientFactory; | ||
this.driverFactory = clientFactory; | ||
this.queryCache = queryCache; | ||
@@ -60,3 +60,3 @@ this.preAggregations = preAggregations; | ||
if (!tables) { | ||
const client = await this.clientFactory(); | ||
const client = await this.driverFactory(); | ||
tables = await client.getTablesQuery(schema); | ||
@@ -129,3 +129,3 @@ await this.redisClient.setAsync(this.tablesRedisKey(), JSON.stringify(tables), 'EX', 120); | ||
this.redisPrefix = redisPrefix; | ||
this.clientFactory = clientFactory; | ||
this.driverFactory = clientFactory; | ||
this.logger = logger; | ||
@@ -173,3 +173,3 @@ this.queryCache = queryCache; | ||
if (!versionEntries.length) { | ||
const client = await this.clientFactory(); | ||
const client = await this.driverFactory(); | ||
await client.createSchemaIfNotExists(this.preAggregation.preAggregationsSchema); | ||
@@ -311,5 +311,6 @@ } | ||
class PreAggregations { | ||
constructor(redisPrefix, clientFactory, logger, queryCache) { | ||
constructor(redisPrefix, clientFactory, logger, queryCache, options) { | ||
this.options = options || {}; | ||
this.redisPrefix = redisPrefix; | ||
this.clientFactory = clientFactory; | ||
this.driverFactory = clientFactory; | ||
this.logger = logger; | ||
@@ -324,3 +325,3 @@ this.queryCache = queryCache; | ||
const preAggregations = queryBody.preAggregations || []; | ||
const loadCache = new PreAggregationLoadCache(this.redisPrefix, this.clientFactory, this.queryCache, this); | ||
const loadCache = new PreAggregationLoadCache(this.redisPrefix, this.driverFactory, this.queryCache, this); | ||
return preAggregations.map(p => | ||
@@ -330,3 +331,3 @@ (preAggregationsTablesToTempTables) => { | ||
this.redisPrefix, | ||
this.clientFactory, | ||
this.driverFactory, | ||
this.logger, | ||
@@ -353,7 +354,7 @@ this.queryCache, | ||
if (!this.queue) { | ||
this.queue = QueryCache.createQueue(`SQL_PRE_AGGREGATIONS_${this.redisPrefix}`, this.clientFactory, (client, q) => { | ||
this.queue = QueryCache.createQueue(`SQL_PRE_AGGREGATIONS_${this.redisPrefix}`, this.driverFactory, (client, q) => { | ||
const { preAggregation, preAggregationsTablesToTempTables, newVersionEntry } = q; | ||
const loader = new PreAggregationLoader( | ||
this.redisPrefix, | ||
this.clientFactory, | ||
this.driverFactory, | ||
this.logger, | ||
@@ -364,6 +365,6 @@ this.queryCache, | ||
preAggregationsTablesToTempTables, | ||
new PreAggregationLoadCache(this.redisPrefix, this.clientFactory, this.queryCache, this) | ||
new PreAggregationLoadCache(this.redisPrefix, this.driverFactory, this.queryCache, this) | ||
); | ||
return loader.refresh(newVersionEntry)(client); | ||
}, { concurrency: 1, logger: this.logger }); | ||
}, { concurrency: 1, logger: this.logger, ...this.options.queueOptions }); | ||
} | ||
@@ -370,0 +371,0 @@ return this.queue; |
@@ -7,5 +7,6 @@ const redis = require('redis'); | ||
class QueryCache { | ||
constructor(redisPrefix, clientFactory, logger) { | ||
constructor(redisPrefix, clientFactory, logger, options) { | ||
this.options = options || {}; | ||
this.redisPrefix = redisPrefix; | ||
this.clientFactory = clientFactory; | ||
this.driverFactory = clientFactory; | ||
this.logger = logger; | ||
@@ -94,5 +95,5 @@ this.redisClient = redis.createClient(process.env.REDIS_URL); | ||
`SQL_QUERY_${this.redisPrefix}`, | ||
this.clientFactory, | ||
this.driverFactory, | ||
(client, q) => client.query(q.query, q.values), | ||
{ logger: this.logger } | ||
{ logger: this.logger, ...this.options.queueOptions } | ||
); | ||
@@ -99,0 +100,0 @@ } |
@@ -5,8 +5,13 @@ const QueryCache = require('./QueryCache'); | ||
class QueryOrchestrator { | ||
constructor(redisPrefix, clientFactory, logger) { | ||
constructor(redisPrefix, driverFactory, logger, options) { | ||
options = options || {}; | ||
this.redisPrefix = redisPrefix; | ||
this.clientFactory = clientFactory; | ||
this.driverFactory = driverFactory; | ||
this.logger = logger; | ||
this.queryCache = new QueryCache(this.redisPrefix, this.clientFactory, this.logger); | ||
this.preAggregations = new PreAggregations(this.redisPrefix, this.clientFactory, this.logger, this.queryCache); | ||
this.queryCache = new QueryCache( | ||
this.redisPrefix, this.driverFactory, this.logger, options.queryCacheOptions | ||
); | ||
this.preAggregations = new PreAggregations( | ||
this.redisPrefix, this.driverFactory, this.logger, this.queryCache, options.preAggregationsOptions | ||
); | ||
} | ||
@@ -13,0 +18,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "Statsbot, Inc.", | ||
"version": "0.0.8", | ||
"version": "0.0.21", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=8.11.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
96619
12
1076
0
10
1
16487