FrankYang0529 commented on code in PR #68625: URL: https://github.com/apache/airflow/pull/68625#discussion_r4162035365
########## providers/apache/kafka/src/airflow/providers/apache/kafka/triggers/shared_stream.py: ########## @@ -0,0 +1,398 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +Shared-stream Kafka trigger and producer for event-driven scheduling. + +Triggers that declare the same ``topics`` + ``kafka_config_id`` share a +single Kafka consumer in the triggerer (one poll loop broadcast to every +subscriber) instead of opening one consumer each. +The :class:`KafkaSharedStreamProducer` owns that consumer and commits +offsets only after the derived :class:`~airflow.triggers.base.TriggerEvent` +instances have been persisted, via the shared-stream ack channel. + +Requires an Airflow version whose ``airflow.triggers.shared_stream`` module +provides the producer-side ack channel. +""" + +from __future__ import annotations + +import logging +from collections.abc import AsyncIterator, Hashable, Sequence +from typing import TYPE_CHECKING, Any, NamedTuple, cast + +from asgiref.sync import sync_to_async +from confluent_kafka import TopicPartition + +from airflow.providers.apache.kafka.hooks.consume import KafkaConsumerHook +from airflow.providers.apache.kafka.hooks.produce import KafkaProducerHook +from airflow.triggers.base import BaseEventTrigger, TriggerEvent +from airflow.triggers.shared_stream import AdvanceItem, SharedStreamProducer Review Comment: Thanks for the suggestion. It now raises `AirflowOptionalProviderFeatureException("Kafka shared-stream triggers need Airflow 3.3+.")`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
