-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
Thấy bạn đang dùng các biến môi trường làm settings.
source SETTINGS.env
export DOCBAO_EXPORT_TO_RABBITMQ=true
export DOCBAO_RABBITMQ_HOST=127.0.0.1
export DOCBAO_RABBITMQ_USERNAME='admin'
export DOCBAO_RABBITMQ_PASSWORD='password'
export DOCBAO_RABBITMQ_EXCHANGE='exchange_name'
export DOCBAO_RABBITMQ_DEFAULT_QUEUE='default_queue_name'
Điều này hơi kì khôi. Biến môi trường chỉ nên dùng một ít để overwrite settings thôi. Biến môi trường có hạn chế:
- Giá trị của nó hoàn toàn là text. Nó không hỗ trợ kiểu dữ liệu đa dạng, dữ liệu đọc lên toàn bộ là text (
"1","true") dẫn tới bạn phải đặt ra luật riêng để "ép kiểu" từ text sang giá trị thực, ví dụ từ "1" thành integer, từ "true", "1", "yes" thành boolean. - Cách gán giá trị cho biến môi trường là đang theo cú pháp của shell, khiến bạn phải viết dính chùm, ví dụ
USERNAME='admin', không thể viết cách cho thông thoáng, dễ nhìnUSERNAME = admin.
Đề xuất giải pháp:
- Dùng file TOML.
Ghi chú:
- Có 1 loại file hay được nhắc đến nhiều hơn là YAML, nhưng so với TOML, YAML có điểm dở là không hỗ trợ kiểu boolean, nên
người ta đặt ra một đống quy ước để biểu diễn giá trị boolean ("0", "1", "true", "false", "yes", "no", "t", "f"...) - Đừng dùng JSON vì file JSON không cho ghi comment.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested