-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: settings fixed. kafka boostrap server set as convention (#50)
- Loading branch information
1 parent
6dee655
commit 3399eb3
Showing
10 changed files
with
47 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import faust | ||
|
||
import settings | ||
from simple_settings import settings | ||
|
||
app = faust.App(**settings.FAUST_CONF) | ||
app = faust.App( | ||
id=1, | ||
autodiscover=["page_views"], | ||
broker=settings.KAFKA_BOOTSTRAP_SERVER, | ||
store=settings.STORE_URI, | ||
logging_config=settings.LOGGING, | ||
topic_allow_declare=settings.TOPIC_ALLOW_DECLARE, | ||
topic_disable_leader=settings.TOPIC_DISABLE_LEADER, | ||
broker_credentials=settings.SSL_CONTEXT, | ||
) |
50 changes: 21 additions & 29 deletions
50
{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,52 @@ | ||
import os | ||
import ssl | ||
from logging.config import dictConfig | ||
|
||
SIMPLE_SETTINGS = { | ||
"OVERRIDE_BY_ENV": True, | ||
"CONFIGURE_LOGGING": True, | ||
"REQUIRED_SETTINGS": ("{{cookiecutter.kafka_server_environment_variable}}",), | ||
"REQUIRED_SETTINGS": ("KAFKA_BOOTSTRAP_SERVER",), | ||
} | ||
|
||
# The following variables can be ovirriden from ENV | ||
{{cookiecutter.kafka_server_environment_variable}} = "kafka://kafka:9092" | ||
KAFKA_BOOTSTRAP_SERVER = "kafka://kafka:9092" | ||
# SCHEMA_REGISTRY_URL = "http://schema-registry:8081" | ||
{% if cookiecutter.include_rocksdb.lower() == "y" %} | ||
STORE_URI = "rocksdb://" | ||
{% else %} | ||
STORE_URI = "memory://" | ||
{% endif %} | ||
|
||
LOGGING = { | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"formatters": {"default": {"format": "%(asctime)s %(levelname)s %(name)s %(message)s"}}, | ||
"handlers": {"console": {"level": "{{cookiecutter.log_level}}", "class": "logging.StreamHandler", "formatter": "default",}}, | ||
"loggers": {"page_views": {"handlers": ["console"], "level": "{{cookiecutter.log_level}}"}}, | ||
} | ||
LOGGING = dictConfig( | ||
{ | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"formatters": {"default": {"format": "%(asctime)s %(levelname)s %(name)s %(message)s"}}, | ||
"handlers": {"console": {"level": "{{cookiecutter.log_level}}", "class": "logging.StreamHandler", "formatter": "default",}}, | ||
"loggers": {"page_views": {"handlers": ["console"], "level": "{{cookiecutter.log_level}}"}}, | ||
} | ||
) | ||
|
||
TOPIC_ALLOW_DECLARE = os.getenv("TOPIC_ALLOW_DECLARE", True) | ||
TOPIC_DISABLE_LEADER = os.getenv("TOPIC_DISABLE_LEADER", False) | ||
|
||
FAUST_CONF = { | ||
"id": 1, | ||
"autodiscover": ["page_views"], | ||
"broker": {{cookiecutter.kafka_server_environment_variable}}, | ||
"store": STORE_URI, | ||
"logging_config": dictConfig(LOGGING), | ||
"topic_allow_declare": TOPIC_ALLOW_DECLARE, | ||
"topic_disable_leader": TOPIC_DISABLE_LEADER, | ||
} | ||
TOPIC_ALLOW_DECLARE = True | ||
TOPIC_DISABLE_LEADER = False | ||
|
||
SSL_ENABLED = os.getenv("SSL_ENABLED", False) | ||
|
||
SSL_ENABLED = False | ||
SSL_CONTEXT = None | ||
|
||
if SSL_ENABLED: | ||
# file in pem format containing the client certificate, as well as any ca certificates | ||
# needed to establish the certificate’s authenticity | ||
KAFKA_SSL_CERT = os.getenv("KAFKA_SSL_CERT", "path_to_ssl_certificate.pem") | ||
KAFKA_SSL_CERT = None | ||
|
||
# filename containing the client private key | ||
KAFKA_SSL_KEY = os.getenv("KAFKA_SSL_KEY", "path_tp_private_key.key") | ||
KAFKA_SSL_KEY = None | ||
|
||
# filename of ca file to use in certificate verification | ||
KAFKA_SSL_CABUNDLE = os.getenv("KAFKA_SSL_CABUNDLE", "path_to_ca_file.crt") | ||
KAFKA_SSL_CABUNDLE = None | ||
|
||
# password for decrypting the client private key | ||
SSL_KEY_PASSWORD = os.getenv("SSL_sKEY_PASSWORD") | ||
SSL_KEY_PASSWORD = None | ||
|
||
SSL_CONTEXT = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile=KAFKA_SSL_CABUNDLE) | ||
|
||
SSL_CONTEXT.load_cert_chain(KAFKA_SSL_CERT, keyfile=KAFKA_SSL_KEY, password=SSL_KEY_PASSWORD) | ||
|
||
FAUST_CONF.update({"broker_credentials": SSL_CONTEXT}) |