mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Add --req-limit-storage redis support
This commit is contained in:
parent
bc8b331fe9
commit
70c4571067
5 changed files with 15 additions and 0 deletions
|
@ -184,6 +184,7 @@ docker-compose -f docker-compose.cuda.yml up -d --build
|
||||||
| --port | Set port to bind the server to | `5000` | LT_PORT |
|
| --port | Set port to bind the server to | `5000` | LT_PORT |
|
||||||
| --char-limit | Set character limit | `No limit` | LT_CHAR_LIMIT |
|
| --char-limit | Set character limit | `No limit` | LT_CHAR_LIMIT |
|
||||||
| --req-limit | Set maximum number of requests per minute per client | `No limit` | LT_REQ_LIMIT |
|
| --req-limit | Set maximum number of requests per minute per client | `No limit` | LT_REQ_LIMIT |
|
||||||
|
| --req-limit-storage | Storage URI to use for request limit data storage. See [Flask Limiter](https://flask-limiter.readthedocs.io/en/stable/configuration.html) | `memory://` | LT_REQ_STORAGE |
|
||||||
| --batch-limit | Set maximum number of texts to translate in a batch request | `No limit` | LT_BATCH_LIMIT |
|
| --batch-limit | Set maximum number of texts to translate in a batch request | `No limit` | LT_BATCH_LIMIT |
|
||||||
| --ga-id | Enable Google Analytics on the API client page by providing an ID | `No tracking` | LT_GA_ID |
|
| --ga-id | Enable Google Analytics on the API client page by providing an ID | `No tracking` | LT_GA_ID |
|
||||||
| --debug | Enable debug environment | `False` | LT_DEBUG |
|
| --debug | Enable debug environment | `False` | LT_DEBUG |
|
||||||
|
|
|
@ -161,6 +161,7 @@ def create_app(args):
|
||||||
default_limits=get_routes_limits(
|
default_limits=get_routes_limits(
|
||||||
args.req_limit, args.daily_req_limit, api_keys_db
|
args.req_limit, args.daily_req_limit, api_keys_db
|
||||||
),
|
),
|
||||||
|
storage_uri=args.req_limit_storage,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
from .no_limiter import Limiter
|
from .no_limiter import Limiter
|
||||||
|
|
|
@ -56,6 +56,11 @@ _default_options_objects = [
|
||||||
'default_value': -1,
|
'default_value': -1,
|
||||||
'value_type': 'int'
|
'value_type': 'int'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'REQ_LIMIT_STORAGE',
|
||||||
|
'default_value': 'memory://',
|
||||||
|
'value_type': 'str'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'DAILY_REQ_LIMIT',
|
'name': 'DAILY_REQ_LIMIT',
|
||||||
'default_value': -1,
|
'default_value': -1,
|
||||||
|
|
|
@ -28,6 +28,13 @@ def get_args():
|
||||||
metavar="<number>",
|
metavar="<number>",
|
||||||
help="Set the default maximum number of requests per minute per client (%(default)s)",
|
help="Set the default maximum number of requests per minute per client (%(default)s)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--req-limit-storage",
|
||||||
|
default=DEFARGS['REQ_LIMIT_STORAGE'],
|
||||||
|
type=str,
|
||||||
|
metavar="<Storage URI>",
|
||||||
|
help="Storage URI to use for request limit data storage. See https://flask-limiter.readthedocs.io/en/stable/configuration.html. (%(default)s)",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--daily-req-limit",
|
"--daily-req-limit",
|
||||||
default=DEFARGS['DAILY_REQ_LIMIT'],
|
default=DEFARGS['DAILY_REQ_LIMIT'],
|
||||||
|
|
|
@ -16,3 +16,4 @@ argos-translate-files==1.1.0
|
||||||
itsdangerous==2.1.2
|
itsdangerous==2.1.2
|
||||||
Werkzeug==2.2.2
|
Werkzeug==2.2.2
|
||||||
requests==2.28.1
|
requests==2.28.1
|
||||||
|
redis==4.3.4
|
||||||
|
|
Loading…
Reference in a new issue