Kafka producer wrapper that sends messages with error handling and logging.
# Source: https://github.com/iflytek/astron-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
from typing import Any, Optional
from confluent_kafka import Producer # type: ignore
from loguru import logger
from workflow.configs import workflow_config
from workflow.extensions.middleware.base import Service, ServiceType
class KafkaProducerService(Service):
"""
Kafka producer service wrapper that provides a high-level interface for sending messages to Kafka topics.
Encapsulates the confluent-kafka Producer with error handling and logging capabilities.
"""
name = ServiceType.KAFKA_PRODUCER_SERVICE
def __init__(self, config: dict):
"""
I
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key