hubcio commented on code in PR #3992:
URL: https://github.com/apache/iggy/pull/3992#discussion_r3950762966
##########
foreign/python/src/config.rs:
##########
@@ -408,16 +409,127 @@ impl TcpConfig {
}
}
+/// Configuration for the HTTP transport, accepted by `IggyClient(...)`.
Review Comment:
you're right, and i was wrong. kind is `#[serde(skip)]`, so the poll gets
served as a plain consumer named after the group. the `[]` i described is TCP.
but your repro passed an explicit partition_id, and `consumer_group(...)`
can't get there. it pins partition_id to None, and the default
`poll_messages_with_strategy_for` rejects a partition-less group poll
client-side with `Feature is unavailable`. so that path always fails. what you
measured needs a direct poll with a partition. docs cover both now.
##########
foreign/python/README.md:
##########
@@ -168,6 +168,11 @@ async def main():
asyncio.run(main())
```
+`IggyClient(...)` also accepts an `HttpConfig` for the HTTP transport. HTTP is
a
+stateless per-request transport, so there is no reconnection policy to
configure.
+There is also no `AutoLogin`: call `login_user(...)` explicitly after
connecting.
Review Comment:
yep, and my wording was wrong. `HttpClient::connect` is a bare `Ok(())` but
`IggyClient::connect` starts the heartbeat after it, so connect() then
login_user() is right and "instead of" wasn't. the class docstring says the
same now so they can't drift.
##########
examples/python/http/producer.py:
##########
@@ -0,0 +1,166 @@
+# 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 typing
+import urllib.parse
+
+from apache_iggy import HttpConfig, IggyClient, StreamDetails, TopicDetails
+from apache_iggy import SendMessage as Message
+from loguru import logger
+
+STREAM_NAME = "sample-stream"
+TOPIC_NAME = "sample-topic"
+STREAM_ID = 0
+TOPIC_ID = 0
+PARTITION_ID = 0
+BATCHES_LIMIT = 5
+
+
+class ArgNamespace(typing.NamedTuple):
+ api_url: str
+ retries: int
+
+
+class ValidateUrl(argparse.Action):
+ def __call__(
+ self,
+ parser: argparse.ArgumentParser,
+ namespace: argparse.Namespace,
+ values: str,
+ _option_string: str | None = None,
+ ):
+ parsed_url: urllib.parse.ParseResult = urllib.parse.urlparse(values)
+ if parsed_url.scheme not in ("http", "https") or parsed_url.netloc ==
"":
+ parser.error(f"Invalid API URL: {values}")
+ setattr(namespace, self.dest, values)
+
+
+def parse_args() -> ArgNamespace:
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--api-url",
+ help="Iggy HTTP API URL",
+ action=ValidateUrl,
+ default="http://127.0.0.1:3000",
+ )
+ parser.add_argument(
+ "--retries",
+ type=int,
+ default=3,
+ help="Number of retries to perform on transient errors",
+ )
+ args = parser.parse_args()
+ return ArgNamespace(**vars(args))
+
+
+def build_config(args: ArgNamespace) -> HttpConfig:
+ """Build an HTTP client configuration."""
+
+ return HttpConfig(
+ api_url=args.api_url,
+ retries=args.retries,
+ )
+
+
+async def main():
+ args: ArgNamespace = parse_args()
+ try:
+ config = build_config(args)
+ except ValueError as error:
+ logger.error(f"Invalid client configuration: {error}")
+ return
+ logger.info(f"Connecting to {args.api_url}")
+
+ client = IggyClient.http(config)
+ logger.info("Connecting to IggyClient")
+ await client.connect()
+ logger.info("Connected.")
+ # HTTP is a stateless transport: log in explicitly rather than relying
Review Comment:
dropped it. the whole `examples/python/http/` dir is gone too, folded into
getting-started as a comment. wording now just names the two real gaps, no
AutoLogin and no reconnection policy.
--
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]