Skip to content

Commit 9660f45

Browse files
committed
BC-269 Configure celery pool type and concurrency number.
1 parent 0b79abc commit 9660f45

File tree

9 files changed

+10
-5
lines changed

9 files changed

+10
-5
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ dot-env:
100100
grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$$(xxd -l 16 -p /dev/urandom)" >> .env
101101
grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env
102102
grep -q -o TNB_NODE_SIGNING_KEY .env || echo "TNB_NODE_SIGNING_KEY=$$(poetry run python -m node.manage generate_signing_key)" >> .env
103+
grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ services:
4747
TNB_DATABASES: '{"default":{"CLIENT":{"host":"node-mongo","password":"${MONGO_INITDB_ROOT_PASSWORD}"}}}'
4848
TNB_CELERY_BROKER_URL: 'amqp://guest:guest@celery-broker:5672//'
4949
env_file: .env
50-
command: poetry run celery -A node.config.celery worker --loglevel=INFO
50+
command: poetry run celery -A node.config.celery worker --loglevel=INFO --concurrency=${TNB_NODE_SCHEDULE_CAPACITY}
5151
depends_on:
5252
- node-mongo
5353
- celery-broker

node/blockchain/inner_models/signed_change_request_message/pv_schedule_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def should_not_be_empty(cls, schedule):
2222

2323
@validator('schedule')
2424
def should_contain_not_more_elements(cls, schedule):
25-
if len(schedule) > (schedule_capacity := settings.SCHEDULE_CAPACITY):
25+
if len(schedule) > (schedule_capacity := settings.NODE_SCHEDULE_CAPACITY):
2626
raise ValidationError(f'Schedule should contain not more than {schedule_capacity} elements')
2727
return schedule
2828

node/blockchain/tests/test_models/test_signed_change_request_message/test_pv_schedule_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def test_schedule_contain_at_least_one_element():
3838

3939
def test_schedule_capacity():
4040
with pytest.raises(
41-
ValidationError, match=f'Schedule should contain not more than {settings.SCHEDULE_CAPACITY} elements'
41+
ValidationError, match=f'Schedule should contain not more than {settings.NODE_SCHEDULE_CAPACITY} elements'
4242
):
4343
PVScheduleUpdateSignedChangeRequestMessage(
44-
schedule={str(n): (str(n) * 64)[:64] for n in range(settings.SCHEDULE_CAPACITY + 1)},
44+
schedule={str(n): (str(n) * 64)[:64] for n in range(settings.NODE_SCHEDULE_CAPACITY + 1)},
4545
account_lock='0' * 64,
4646
)
4747

node/config/settings/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
if not is_pytest_running():
3838
assert SECRET_KEY is not NotImplemented # type: ignore # noqa: F821
3939
assert NODE_SIGNING_KEY is not NotImplemented # type: ignore # noqa: F821
40+
assert NODE_SCHEDULE_CAPACITY is not NotImplemented # type: ignore # noqa: F821

node/config/settings/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
NODE_LIST_JSON_PATH = None
1313
SYNC_BATCH_SIZE = 10
14-
SCHEDULE_CAPACITY = 20
14+
NODE_SCHEDULE_CAPACITY = NotImplemented
1515

1616
SUPPRESS_WARNINGS_TB = True
1717

node/config/settings/templates/settings.dev.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
DATABASES['default']['CLIENT']['connectTimeoutMS'] = 1000
1818

1919
NODE_SIGNING_KEY = 'a37e2836805975f334108b55523634c995bd2a4db610062f404510617e83126f'
20+
NODE_SCHEDULE_CAPACITY = 20

node/core/tests/fixtures/misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_settings(settings):
2020
NODE_SIGNING_KEY='a025da120a1c95b27f17bb9442af9c27d3a357733aa150b458f21682a2d539a9',
2121
CELERY_BROKER_URL='memory://',
2222
CELERY_TASK_ALWAYS_EAGER=True,
23+
NODE_SCHEDULE_CAPACITY=20,
2324
):
2425
# For some reason we need to import the app to make celery settings work
2526
from node.config.celery import app # noqa: F401

scripts/deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ echo 'Creating/updating .env file...'
3232
test -f .env || touch .env
3333
grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$(xxd -l 16 -p /dev/urandom)" >> .env
3434
grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env
35+
grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env
3536

3637
docker-compose pull
3738

0 commit comments

Comments
 (0)