Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import json
import os

from pendulum import datetime

Expand All @@ -32,19 +33,15 @@
# This is just for setting up connections in the demo - you should use standard
# methods for setting these connections in production
from airflow.providers.standard.operators.python import PythonOperator
from airflow.utils import db


def load_connections():
db.merge_conn(
conns = [
Connection(
conn_id="fizz_buzz_1",
conn_type="kafka",
extra=json.dumps({"socket.timeout.ms": 10, "bootstrap.servers": "broker:29092"}),
)
)

db.merge_conn(
),
Connection(
conn_id="fizz_buzz_2",
conn_type="kafka",
Expand All @@ -56,8 +53,12 @@ def load_connections():
"auto.offset.reset": "beginning",
}
),
)
)
),
]

for c in conns:
envvar = f"AIRFLOW_CONN_{c.conn_id.upper()}"
os.environ[envvar] = c.get_uri()


def _producer_function():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import functools
import json
import logging
import os
from datetime import datetime, timedelta

from airflow import DAG
Expand All @@ -41,17 +42,13 @@
def load_connections():
# Connections needed for this example dag to finish
from airflow.models import Connection
from airflow.utils import db

db.merge_conn(
conns = [
Connection(
conn_id="t1-3",
conn_type="kafka",
extra=json.dumps({"socket.timeout.ms": 10, "bootstrap.servers": "broker:29092"}),
)
)

db.merge_conn(
),
Connection(
conn_id="t2",
conn_type="kafka",
Expand All @@ -63,10 +60,7 @@ def load_connections():
"auto.offset.reset": "beginning",
}
),
)
)

db.merge_conn(
),
Connection(
conn_id="t4",
conn_type="kafka",
Expand All @@ -78,10 +72,7 @@ def load_connections():
"auto.offset.reset": "beginning",
}
),
)
)

db.merge_conn(
),
Connection(
conn_id="t4b",
conn_type="kafka",
Expand All @@ -93,10 +84,7 @@ def load_connections():
"auto.offset.reset": "beginning",
}
),
)
)

db.merge_conn(
),
Connection(
conn_id="t5",
conn_type="kafka",
Expand All @@ -108,8 +96,12 @@ def load_connections():
"auto.offset.reset": "beginning",
}
),
)
)
),
]

for c in conns:
envvar = f"AIRFLOW_CONN_{c.conn_id.upper()}"
os.environ[envvar] = c.get_uri()


def producer_function():
Expand Down