himanchalkaushale commented on code in PR #4710: URL: https://github.com/apache/iggy/pull/4710#discussion_r4470359927
########## examples/python/sink-data-producer/producer.py: ########## @@ -0,0 +1,137 @@ +# 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. + +import argparse +import asyncio +import json +import os +import random +import string +from datetime import UTC, datetime, timedelta +from typing import NamedTuple +from urllib.parse import quote + +from apache_iggy import DirectProducerConfig, IggyClient, Partitioning +from apache_iggy import SendMessage as Message +from loguru import logger + +STREAM_NAME = os.getenv("IGGY_STREAM", "qw") +TOPIC_NAME = os.getenv("IGGY_TOPIC", "records") + +SOURCES = ["browser", "mobile", "desktop", "email", "network", "other"] +STATES = ["active", "inactive", "blocked", "deleted", "unknown"] +DOMAINS = [ + "gmail.com", + "yahoo.com", + "hotmail.com", + "outlook.com", + "aol.com", +] + +MAX_BATCHES = 100 +MIN_RECORDS_PER_BATCH = 100 +MAX_RECORDS_PER_BATCH = 500 + + +class ArgNamespace(NamedTuple): + connection_string: str + + +def parse_args() -> ArgNamespace: + address = os.getenv("IGGY_ADDRESS", "127.0.0.1:8090") + username = os.getenv("IGGY_USERNAME", "iggy") + password = os.getenv("IGGY_PASSWORD", "iggy") + encoded_username = quote(username, safe="") # noqa: S311 + encoded_password = quote(password, safe="") # noqa: S311 Review Comment: @hubcio Updated credential handling to use TcpConfig with AutoLogin.username_password() for environment credentials, removed percent-encoding, and preserved the explicit CLI connection-string override. -- 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]
