settings.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright © 2023 Ingram Micro Inc. All rights reserved.
  2. import os
  3. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  4. SECRET_KEY = '6^1@%4#qtc+bookwp4w5k-+nbo+clm!skzdhnyl@rf&06b5tl7'
  5. DEBUG = True
  6. ALLOWED_HOSTS = []
  7. # Application definition
  8. INSTALLED_APPS = [
  9. 'django.contrib.auth',
  10. 'django.contrib.contenttypes',
  11. 'django.contrib.sessions',
  12. 'django.contrib.messages',
  13. 'dj_cqrs',
  14. 'tests.dj_master',
  15. 'tests.dj_replica',
  16. ]
  17. MIDDLEWARE = [
  18. 'django.middleware.security.SecurityMiddleware',
  19. 'django.contrib.sessions.middleware.SessionMiddleware',
  20. 'django.middleware.common.CommonMiddleware',
  21. 'django.middleware.csrf.CsrfViewMiddleware',
  22. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  23. 'django.contrib.messages.middleware.MessageMiddleware',
  24. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  25. ]
  26. ROOT_URLCONF = 'tests.dj.urls'
  27. DB_ENGINE = os.getenv('DB', 'sqlite') or 'sqlite'
  28. if DB_ENGINE == 'postgres':
  29. DATABASES = {
  30. 'default': {
  31. 'ENGINE': 'django.db.backends.postgresql',
  32. 'HOST': 'postgres',
  33. 'NAME': 'django_cqrs',
  34. 'USER': 'user',
  35. 'PASSWORD': 'pswd',
  36. },
  37. }
  38. elif DB_ENGINE == 'mysql':
  39. DATABASES = {
  40. 'default': {
  41. 'ENGINE': 'django.db.backends.mysql',
  42. 'HOST': 'mysql',
  43. 'NAME': 'django_cqrs',
  44. 'USER': 'root',
  45. 'PASSWORD': 'password',
  46. },
  47. }
  48. else:
  49. DATABASES = {
  50. 'default': {
  51. 'ENGINE': 'django.db.backends.sqlite3',
  52. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  53. },
  54. }
  55. LANGUAGE_CODE = 'en-us'
  56. TIME_ZONE = 'UTC'
  57. USE_I18N = True
  58. USE_L10N = True
  59. USE_TZ = True
  60. CQRS = {
  61. 'transport': 'tests.dj.transport.TransportStub',
  62. 'queue': 'replica',
  63. 'master': {
  64. 'CQRS_MESSAGE_TTL': 3600,
  65. },
  66. 'replica': {
  67. 'CQRS_MAX_RETRIES': 5,
  68. 'CQRS_RETRY_DELAY': 1,
  69. 'delay_queue_max_size': 1000,
  70. 'dead_letter_queue': 'dead_letter_replica',
  71. 'dead_message_ttl': 5,
  72. },
  73. }