rename gzip to isGzip
This commit is contained in:
parent
87fd9db1fe
commit
4fab96cb3a
@ -133,9 +133,9 @@ function handleCopyFrom (logger) {
|
|||||||
return function handleCopyFromMiddleware (req, res, next) {
|
return function handleCopyFromMiddleware (req, res, next) {
|
||||||
const sql = req.query.q;
|
const sql = req.query.q;
|
||||||
const { userDbParams, user } = res.locals;
|
const { userDbParams, user } = res.locals;
|
||||||
const gzip = req.get('content-encoding') === 'gzip';
|
const isGzip = req.get('content-encoding') === 'gzip';
|
||||||
|
|
||||||
let metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, gzip);
|
let metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, isGzip);
|
||||||
|
|
||||||
streamCopy.from(
|
streamCopy.from(
|
||||||
sql,
|
sql,
|
||||||
@ -172,7 +172,7 @@ function handleCopyFrom (logger) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('data', data => {
|
.on('data', data => {
|
||||||
if (gzip) {
|
if (isGzip) {
|
||||||
metrics.addGzipSize(data.length);
|
metrics.addGzipSize(data.length);
|
||||||
} else {
|
} else {
|
||||||
metrics.addSize(data.length);
|
metrics.addSize(data.length);
|
||||||
@ -181,7 +181,7 @@ function handleCopyFrom (logger) {
|
|||||||
.on('end', () => requestEnded = true);
|
.on('end', () => requestEnded = true);
|
||||||
|
|
||||||
|
|
||||||
if (gzip) {
|
if (isGzip) {
|
||||||
req
|
req
|
||||||
.pipe(zlib.createGunzip())
|
.pipe(zlib.createGunzip())
|
||||||
.on('data', data => metrics.addSize(data.length))
|
.on('data', data => metrics.addSize(data.length))
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
const { getFormatFromCopyQuery } = require('../utils/query_info');
|
const { getFormatFromCopyQuery } = require('../utils/query_info');
|
||||||
|
|
||||||
module.exports = class StreamCopyMetrics {
|
module.exports = class StreamCopyMetrics {
|
||||||
constructor(logger, type, sql, user, gzip = null) {
|
constructor(logger, type, sql, user, isGzip = null) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.format = getFormatFromCopyQuery(sql);
|
this.format = getFormatFromCopyQuery(sql);
|
||||||
this.gzip = gzip;
|
this.isGzip = isGzip;
|
||||||
this.username = user;
|
this.username = user;
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
this.gzipSize = 0;
|
this.gzipSize = 0;
|
||||||
@ -49,7 +49,7 @@ module.exports = class StreamCopyMetrics {
|
|||||||
|
|
||||||
this._log(
|
this._log(
|
||||||
this.startTime.toISOString(),
|
this.startTime.toISOString(),
|
||||||
this.gzip && this.gzipSize ? this.gzipSize : null,
|
this.isGzip && this.gzipSize ? this.gzipSize : null,
|
||||||
this.error ? this.error.message : null
|
this.error ? this.error.message : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ module.exports = class StreamCopyMetrics {
|
|||||||
format: this.format,
|
format: this.format,
|
||||||
size: this.size,
|
size: this.size,
|
||||||
rows: this.rows,
|
rows: this.rows,
|
||||||
gzip: this.gzip,
|
gzip: this.isGzip,
|
||||||
username: this.username,
|
username: this.username,
|
||||||
time: this.time,
|
time: this.time,
|
||||||
timestamp
|
timestamp
|
||||||
|
Loading…
Reference in New Issue
Block a user