Вырезал из кода ненужный asserBatchSize.
This commit is contained in:
@@ -8,8 +8,5 @@ INGEST_API_KEY=
|
|||||||
# Pool sizing for node-postgres.
|
# Pool sizing for node-postgres.
|
||||||
PG_POOL_MAX=20
|
PG_POOL_MAX=20
|
||||||
|
|
||||||
# Maximum points accepted by one POST /ingest request.
|
|
||||||
INGEST_MAX_BATCH_SIZE=10000
|
|
||||||
|
|
||||||
# Poll interval for GET /current/events SSE snapshots.
|
# Poll interval for GET /current/events SSE snapshots.
|
||||||
CURRENT_EVENTS_POLL_MS=1000
|
CURRENT_EVENTS_POLL_MS=1000
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ DATABASE_URL=postgres://greact:pG3526l4@194.36.208.86:5433/cloud
|
|||||||
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
|
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
|
||||||
INGEST_API_KEY=
|
INGEST_API_KEY=
|
||||||
PG_POOL_MAX=20
|
PG_POOL_MAX=20
|
||||||
INGEST_MAX_BATCH_SIZE=10000
|
|
||||||
CURRENT_EVENTS_POLL_MS=1000
|
CURRENT_EVENTS_POLL_MS=1000
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ services:
|
|||||||
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
|
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
|
||||||
INGEST_API_KEY: ${INGEST_API_KEY}
|
INGEST_API_KEY: ${INGEST_API_KEY}
|
||||||
PG_POOL_MAX: ${PG_POOL_MAX}
|
PG_POOL_MAX: ${PG_POOL_MAX}
|
||||||
INGEST_MAX_BATCH_SIZE: ${INGEST_MAX_BATCH_SIZE}
|
|
||||||
CURRENT_EVENTS_POLL_MS: ${CURRENT_EVENTS_POLL_MS}
|
CURRENT_EVENTS_POLL_MS: ${CURRENT_EVENTS_POLL_MS}
|
||||||
ports:
|
ports:
|
||||||
- "${PORT}:${PORT}"
|
- "${PORT}:${PORT}"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { DbService } from '../db/db.service';
|
import { DbService } from '../db/db.service';
|
||||||
import { IngestPointDto } from './dto/ingest-point.dto';
|
import { IngestPointDto } from './dto/ingest-point.dto';
|
||||||
|
|
||||||
@@ -23,8 +23,6 @@ export class IngestService {
|
|||||||
return { processed: 0 };
|
return { processed: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
this.assertBatchSize(points.length);
|
|
||||||
|
|
||||||
const normalized: NormalizedPoint[] = points.map((point) => ({
|
const normalized: NormalizedPoint[] = points.map((point) => ({
|
||||||
edge: point.edge,
|
edge: point.edge,
|
||||||
tag: point.tag,
|
tag: point.tag,
|
||||||
@@ -83,14 +81,4 @@ export class IngestService {
|
|||||||
|
|
||||||
return { processed: normalized.length };
|
return { processed: normalized.length };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Защищает API от слишком больших ingest-запросов, занимающих соединение с БД надолго. */
|
|
||||||
private assertBatchSize(size: number): void {
|
|
||||||
const maxBatchSize = Number(process.env.INGEST_MAX_BATCH_SIZE);
|
|
||||||
|
|
||||||
if (size > maxBatchSize) {
|
|
||||||
throw new BadRequestException(`Batch size must not exceed ${maxBatchSize} points.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user