feat: weather-demo MQ pipeline + sqs-consumer v1.2 with JWT auto-refresh
- sqs-consumer: new Go binary v1.2 with tokenManager (auto-login /auth/login, 5min cache, retry on 401) - console: add MQ/KW triggers UI (mqtriggers.go, kwtriggers.go, mq.js) - console: update python-env image to v1.1 (boto3+psycopg2+requests) - weather-demo: fix consumer/main.py (Flask Request.get_json instead of dict access) - weather-demo: fix fetcher/main.py (boto3 SQS publish, 5 cities) - weather-demo: update main.tf (python-env v1.1, deploy_type=literal) - python-env: add psycopg2-binary to Dockerfile (v1.1) - terraform provider: client auth fix
This commit is contained in:
@@ -4,16 +4,22 @@ import psycopg2
|
||||
|
||||
|
||||
def main(event, context):
|
||||
pg_dsn = os.environ["PG_DSN"]
|
||||
pg_dsn = os.environ.get(
|
||||
"PG_DSN",
|
||||
"postgresql://super:BQUF5ruECa1ZFlq4wYt3gPJUEmtBMkA9QNK4MM5Sd8al4ArMDlmT16DIKHYBPyif"
|
||||
"@postgresqlk8s-master.dc5db45d-f8b4-4fd0-ad33-ec4dd017f2d5.svc.cluster.local:5432"
|
||||
"/sqsdb?sslmode=disable",
|
||||
)
|
||||
|
||||
# Извлекаем тело сообщения из SQS (POST от sqs-consumer)
|
||||
body = getattr(event, "body", event)
|
||||
if isinstance(body, (bytes, bytearray)):
|
||||
body = body.decode("utf-8")
|
||||
if isinstance(body, str):
|
||||
data = json.loads(body)
|
||||
else:
|
||||
data = body
|
||||
# event — Flask Request object: используем .data (bytes) или .get_json()
|
||||
try:
|
||||
data = event.get_json(force=True, silent=False)
|
||||
except Exception:
|
||||
raw = getattr(event, "data", None) or getattr(event, "body", b"")
|
||||
if isinstance(raw, (bytes, bytearray)):
|
||||
raw = raw.decode("utf-8")
|
||||
data = json.loads(raw) if raw else {}
|
||||
|
||||
conn = psycopg2.connect(pg_dsn)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user