Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
fix(config): plugin defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Frazer Smith committed Apr 30, 2021
1 parent cbf405d commit 0e07cfc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
18 changes: 9 additions & 9 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ CORS_EXPOSED_HEADERS=

### PROCESS LOAD HANDLING #################################

# Defaults to 1000
PROC_LOAD_MAX_EVENT_LOOP_DELAY=
# Defaults to 0 (disabled)
PROC_LOAD_MAX_EVENT_LOOP_DELAY=1000

# Defaults to 100000000
PROC_LOAD_MAX_HEAP_USED_BYTES=
# Defaults to 0 (disabled)
PROC_LOAD_MAX_HEAP_USED_BYTES=100000000

# Defaults to 100000000
PROC_LOAD_MAX_RSS_BYTES=
# Defaults to 0 (disabled)
PROC_LOAD_MAX_RSS_BYTES=100000000

# Defaults to 0.98
PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION=
# Defaults to 0 (disabled)
PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION=0.98

### RATE LIMITING #########################################

# List of IPs that are excluded from rate limiting
RATE_LIMIT_EXCLUDED_ARRAY=

# Maximum number of connections per minute per client
# Defaults to 10
# Defaults to 1000
RATE_LIMIT_MAX_CONNECTIONS_PER_MIN=2500

### LOGGER ################################################
Expand Down
8 changes: 4 additions & 4 deletions src/config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe("configuration", () => {
const CORS_ORIGIN = false;
const CORS_ALLOWED_HEADERS = "";
const CORS_ALLOW_CREDENTIALS = "";
const PROC_LOAD_MAX_EVENT_LOOP_DELAY = 5000;
const PROC_LOAD_MAX_HEAP_USED_BYTES = 5000;
const PROC_LOAD_MAX_RSS_BYTES = 5000;
const PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION = 1.0;
const PROC_LOAD_MAX_EVENT_LOOP_DELAY = 1000;
const PROC_LOAD_MAX_HEAP_USED_BYTES = 100000000;
const PROC_LOAD_MAX_RSS_BYTES = 100000000;
const PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION = 0.98;
const RATE_LIMIT_MAX_CONNECTIONS_PER_MIN = 2000;
const RATE_LIMIT_EXCLUDED_ARRAY = '["127.0.0.1"]';
const LOG_LEVEL = faker.random.arrayElement([
Expand Down
21 changes: 11 additions & 10 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,24 @@ async function getConfig() {
.prop("CORS_EXPOSED_HEADERS", S.anyOf([S.string(), S.null()]))
.prop(
"PROC_LOAD_MAX_EVENT_LOOP_DELAY",
S.anyOf([S.number(), S.null()]).default(1000)
S.anyOf([S.number(), S.null()]).default(0)
)
.prop(
"PROC_LOAD_MAX_HEAP_USED_BYTES",
S.anyOf([S.number(), S.null()]).default(100000000)
S.anyOf([S.number(), S.null()]).default(0)
)
.prop(
"PROC_LOAD_MAX_RSS_BYTES",
S.anyOf([S.number(), S.null()]).default(100000000)
S.anyOf([S.number(), S.null()]).default(0)
)
.prop(
"PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION",
S.anyOf([S.number(), S.null()]).default(0.98)
S.anyOf([S.number(), S.null()]).default(0)
)
.prop("RATE_LIMIT_EXCLUDED_ARRAY", S.anyOf([S.string(), S.null()]))
.prop(
"RATE_LIMIT_MAX_CONNECTIONS_PER_MIN",
S.anyOf([S.number(), S.null()]).default(10)
S.anyOf([S.number(), S.null()]).default(1000)
)
.prop(
"LOG_LEVEL",
Expand Down Expand Up @@ -152,13 +152,14 @@ async function getConfig() {
origin: parseCorsParameter(env.CORS_ORIGIN) || false,
},
processLoad: {
maxEventLoopDelay: env.PROC_LOAD_MAX_EVENT_LOOP_DELAY,
maxHeapUsedBytes: env.PROC_LOAD_MAX_HEAP_USED_BYTES,
maxRssBytes: env.PROC_LOAD_MAX_RSS_BYTES,
maxEventLoopUtilization: env.PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION,
maxEventLoopDelay: env.PROC_LOAD_MAX_EVENT_LOOP_DELAY || 0,
maxHeapUsedBytes: env.PROC_LOAD_MAX_HEAP_USED_BYTES || 0,
maxRssBytes: env.PROC_LOAD_MAX_RSS_BYTES || 0,
maxEventLoopUtilization:
env.PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION || 0,
},
rateLimit: {
max: env.RATE_LIMIT_MAX_CONNECTIONS_PER_MIN,
max: env.RATE_LIMIT_MAX_CONNECTIONS_PER_MIN || 1000,
timeWindow: 60000,
},
swagger: {
Expand Down

0 comments on commit 0e07cfc

Please sign in to comment.