This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
119 lines (107 loc) · 4.59 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
##################################################
# features Settings File
##################################################
import os
from schema import SCHEMA
from fastavro import schema
EXTRACTOR = os.environ["FEATURE_EXTRACTOR"]
CONSUMER_CONFIG = {
"CLASS": "apf.consumers.KafkaConsumer",
"TOPICS": os.environ["CONSUMER_TOPICS"].strip().split(","),
"PARAMS": {
"bootstrap.servers": os.environ["CONSUMER_SERVER"],
"group.id": os.environ["CONSUMER_GROUP_ID"],
"auto.offset.reset": "beginning",
"max.poll.interval.ms": 3600000,
"enable.partition.eof": os.getenv("ENABLE_PARTITION_EOF", False),
},
"consume.timeout": int(os.getenv("CONSUME_TIMEOUT", 10)),
"consume.messages": int(os.getenv("CONSUME_MESSAGES", 1000)),
}
PRODUCER_CONFIG = {
"CLASS": "apf.producers.KafkaProducer",
"TOPIC": os.environ["PRODUCER_TOPIC"],
"PARAMS": {
"bootstrap.servers": os.environ["PRODUCER_SERVER"],
},
"SCHEMA": SCHEMA,
}
SCRIBE_PRODUCER_CONFIG = {
"CLASS": "apf.producers.KafkaProducer",
"PARAMS": {
"bootstrap.servers": os.environ["SCRIBE_SERVER"],
},
"TOPIC": os.environ["SCRIBE_TOPIC"],
"SCHEMA": schema.load_schema("scribe_schema.avsc"),
}
METRICS_CONFIG = {
"CLASS": "apf.metrics.KafkaMetricsProducer",
"EXTRA_METRICS": [
{"key": "aid", "alias": "aid"},
],
"PARAMS": {
"PARAMS": {
"bootstrap.servers": os.environ["METRICS_HOST"],
"auto.offset.reset": "smallest",
},
"TOPIC": os.environ["METRICS_TOPIC"],
"SCHEMA": {
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://example.com/example.json",
"type": "object",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": {},
"examples": [
{"timestamp_sent": "2020-09-01", "timestamp_received": "2020-09-01"}
],
"required": ["timestamp_sent", "timestamp_received"],
"properties": {
"timestamp_sent": {
"$id": "#/properties/timestamp_sent",
"type": "string",
"title": "The timestamp_sent schema",
"description": "Timestamp sent refers to the time at which a message is sent.",
"default": "",
"examples": ["2020-09-01"],
},
"timestamp_received": {
"$id": "#/properties/timestamp_received",
"type": "string",
"title": "The timestamp_received schema",
"description": "Timestamp received refers to the time at which a message is received.",
"default": "",
"examples": ["2020-09-01"],
},
},
"additionalProperties": True,
},
},
}
if os.getenv("KAFKA_USERNAME") and os.getenv("KAFKA_PASSWORD"):
CONSUMER_CONFIG["PARAMS"]["security.protocol"] = "SASL_SSL"
CONSUMER_CONFIG["PARAMS"]["sasl.mechanism"] = "SCRAM-SHA-512"
CONSUMER_CONFIG["PARAMS"]["sasl.username"] = os.getenv("KAFKA_USERNAME")
CONSUMER_CONFIG["PARAMS"]["sasl.password"] = os.getenv("KAFKA_PASSWORD")
PRODUCER_CONFIG["PARAMS"]["security.protocol"] = "SASL_SSL"
PRODUCER_CONFIG["PARAMS"]["sasl.mechanism"] = "SCRAM-SHA-512"
PRODUCER_CONFIG["PARAMS"]["sasl.username"] = os.getenv("KAFKA_USERNAME")
PRODUCER_CONFIG["PARAMS"]["sasl.password"] = os.getenv("KAFKA_PASSWORD")
SCRIBE_PRODUCER_CONFIG["PARAMS"]["security.protocol"] = "SASL_SSL"
SCRIBE_PRODUCER_CONFIG["PARAMS"]["sasl.mechanism"] = "SCRAM-SHA-512"
SCRIBE_PRODUCER_CONFIG["PARAMS"]["sasl.username"] = os.getenv("KAFKA_USERNAME")
SCRIBE_PRODUCER_CONFIG["PARAMS"]["sasl.password"] = os.getenv("KAFKA_PASSWORD")
METRICS_CONFIG["PARAMS"]["PARAMS"]["security.protocol"] = "SASL_SSL"
METRICS_CONFIG["PARAMS"]["PARAMS"]["sasl.mechanism"] = "SCRAM-SHA-512"
METRICS_CONFIG["PARAMS"]["PARAMS"]["sasl.username"] = os.getenv("KAFKA_USERNAME")
METRICS_CONFIG["PARAMS"]["PARAMS"]["sasl.password"] = os.getenv("KAFKA_PASSWORD")
use_profiling = bool(os.getenv("USE_PROFILING", True))
pyroscope_server = os.getenv("PYROSCOPE_SERVER", "http://pyroscope.pyroscope:4040")
STEP_CONFIG = {
"CONSUMER_CONFIG": CONSUMER_CONFIG,
"PRODUCER_CONFIG": PRODUCER_CONFIG,
"SCRIBE_PRODUCER_CONFIG": SCRIBE_PRODUCER_CONFIG,
"METRICS_CONFIG": METRICS_CONFIG,
"USE_PROFILING": use_profiling,
"PYROSCOPE_SERVER": pyroscope_server,
}