44from airflow .operators .python_operator import PythonOperator
55
66from dags_config import Config as config
7- from rss_news import export_news_to_broker
8- from proxypool import update_proxypool
7+ from custom_operators import (
8+ ProxyPoolOperator ,
9+ RSSNewsOperator
10+ )
911
1012
1113def extract_feed_name (url ):
@@ -19,12 +21,15 @@ def dummy_callable(action):
1921
2022def export_events (config , rss_feed , language , dag ):
2123 feed_name = extract_feed_name (rss_feed )
22- return PythonOperator (
24+ return RSSNewsOperator (
2325 task_id = f"exporting_{ feed_name } _news_to_broker" ,
24- python_callable = export_news_to_broker ,
25- op_kwargs = {
26- "config" : config , "rss_feed" : rss_feed , "language" : language
27- },
26+ validator_config = config .VALIDATOR_CONFIG ,
27+ rss_feed = rss_feed ,
28+ language = language ,
29+ redis_config = config .REDIS_CONFIG ,
30+ redis_key = config .REDIS_KEY ,
31+ bootstrap_servers = config .BOOTSTRAP_SERVERS ,
32+ topic = config .TOPIC ,
2833 dag = dag
2934 )
3035
@@ -46,10 +51,14 @@ def create_dag(dag_id, interval, config, language, rss_feeds):
4651 dag = dag
4752 )
4853
49- proxypool = PythonOperator (
54+ proxypool = ProxyPoolOperator (
5055 task_id = "updating_proxypoool" ,
51- python_callable = update_proxypool ,
52- op_kwargs = {"config" : config },
56+ proxy_webpage = config .PROXY_WEBPAGE ,
57+ number_of_proxies = config .NUMBER_OF_PROXIES ,
58+ testing_url = config .TESTING_URL ,
59+ max_workers = config .NUMBER_OF_PROXIES ,
60+ redis_config = config .REDIS_CONFIG ,
61+ redis_key = config .REDIS_KEY ,
5362 dag = dag
5463 )
5564
@@ -76,5 +85,9 @@ def create_dag(dag_id, interval, config, language, rss_feeds):
7685 interval = f"{ n * 4 } -59/10 * * * *"
7786
7887 globals ()[dag_id ] = create_dag (
79- dag_id , interval , config , language , rss_feeds
88+ dag_id ,
89+ interval ,
90+ config ,
91+ language ,
92+ rss_feeds
8093 )
0 commit comments