Python SDK: expose client disconnect and shutdown lifecycle methods
- Dominant language
- Rust
- Stars
- 4.9k
- Forks
- 432
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 173
Description
### Description
The Rust `Client` trait exposes both `disconnect()` and `shutdown()`, while the Python `IggyClient` currently exposes only `connect()`.
`disconnect()` closes the current connection while allowing the client to connect again. `shutdown()` releases the underlying client resources and is terminal for binary transports.
This covers B7 and B8 of the Python SDK parity work tracked in #3893.
```rust
async fn disconnect(&self) -> Result<(), IggyError>;
async fn shutdown(&self) -> Result<(), IggyError>;
```
### Affected area / component
Python SDK
### Proposed solution
- Add asynchronous `disconnect()` and `shutdown()` methods to the `#[pymethods]` block in `foreign/python/src/client.rs`.
- Delegate directly to the corresponding Rust `IggyClient` methods and map failures through the existing `to_runtime_error` helper.
- Regenerate `foreign/python/apache_iggy.pyi`, with both methods returning `Awaitable[None]`.
- Extend `foreign/python/tests/test_connectivity.py` to verify:
- `disconnect()` is idempotent.
- Requests fail while disconnected.
- A disconnected client can connect and authenticate again.
- `shutdown()` is idempotent.
- Requests after shutdown fail with the underlying client-shutdown error.
- Document transport-specific behavior, including the no-op lifecycle used by HTTP.
No new wrapper types are needed.
### Alternatives considered
Expose only `disconnect()`. This would leave Python without the terminal cleanup operation provided by the Rust client.
### Contribution
- [ ] I'm willing to submit a pull request to implement this feature
### Good first issue
- [x] I think this could be a good first issue for a new contributor
Contributor guide
Research direction
Start in foreign/python/src/client.rs and inspect the existing #[pymethods] block and to_runtime_error helper, then compare the Rust Client trait methods. Update the generated foreign/python/apache_iggy.pyi and extend foreign/python/tests/test_connectivity.py for idempotence, reconnecting, disconnected requests, and shutdown failures. Done means the tests cover both lifecycle methods and the transport-specific behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- api, documentation, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100