ethanlin01x commented on code in PR #3776:
URL: https://github.com/apache/iggy/pull/3776#discussion_r3723569730
##########
foreign/python/src/client.rs:
##########
@@ -56,17 +57,41 @@ pub struct IggyClient {
#[gen_stub_pymethods]
#[pymethods]
impl IggyClient {
- /// Constructs a new IggyClient from a TCP server address.
+ /// Constructs a new IggyClient from a TCP server address or a `TcpConfig`.
/// This initializes a new runtime for asynchronous operations.
/// Future versions might utilize asyncio for more Pythonic async.
+ ///
+ /// Args:
+ /// conn: Either a `host:port` address, or a `TcpConfig` carrying the
full
+ /// transport configuration. Defaults to `127.0.0.1:8090` with
auto-login
+ /// disabled.
+ ///
+ /// Raises:
+ /// RuntimeError: If the address is not a valid `host:port` pair, or
if the
+ /// client cannot be built.
#[new]
#[pyo3(signature = (conn=None))]
fn new(
- #[gen_stub(override_type(type_repr = "builtins.str | None"))] conn:
Option<String>,
+ #[gen_stub(override_type(type_repr = "TcpConfig | builtins.str |
None"))] conn: Option<
+ PyClientConfig,
+ >,
) -> PyResult<Self> {
+ let config = match conn {
+ Some(PyClientConfig::Config(config)) => config.client_config(),
+ Some(PyClientConfig::ServerAddress(server_address)) => Arc::new(
+ TcpClientConfigBuilder::new()
+ .with_server_address(server_address)
+ .build()
+ .map_err(|e| {
+ PyErr::new::<pyo3::exceptions::PyRuntimeError,
_>(e.to_string())
+ })?,
+ ),
+ None => Arc::new(TcpClientConfig::default()),
+ };
+ let tcp_client = TcpClient::create(config)
+ .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError,
_>(e.to_string()))?;
let client = IggyClientBuilder::new()
Review Comment:
Fixed in acd01f68e.
--
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]