-
Notifications
You must be signed in to change notification settings - Fork 348
feat(python): add topic listing, update, delete and purge #3572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ce94a0d
93042e3
98f00e1
50d5505
15310b3
6db5ccf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,46 @@ | |
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use iggy::prelude::TopicDetails as RustTopicDetails; | ||
| use iggy::prelude::{Topic as RustTopic, TopicDetails as RustTopicDetails}; | ||
| use pyo3::prelude::*; | ||
| use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pymethods}; | ||
|
|
||
| #[gen_stub_pyclass] | ||
| #[pyclass] | ||
| pub struct Topic { | ||
| pub(crate) inner: RustTopic, | ||
| } | ||
|
|
||
| impl From<RustTopic> for Topic { | ||
| fn from(topic: RustTopic) -> Self { | ||
| Self { inner: topic } | ||
| } | ||
| } | ||
|
|
||
| #[gen_stub_pymethods] | ||
| #[pymethods] | ||
| impl Topic { | ||
| #[getter] | ||
| pub fn id(&self) -> u32 { | ||
| self.inner.id | ||
| } | ||
|
|
||
| #[getter] | ||
| pub fn name(&self) -> String { | ||
| self.inner.name.to_string() | ||
| } | ||
|
|
||
| #[getter] | ||
| pub fn messages_count(&self) -> u64 { | ||
| self.inner.messages_count | ||
| } | ||
|
|
||
| #[getter] | ||
| pub fn partitions_count(&self) -> u32 { | ||
| self.inner.partitions_count | ||
| } | ||
| } | ||
|
|
||
| #[gen_stub_pyclass] | ||
| #[pyclass] | ||
| pub struct TopicDetails { | ||
|
|
@@ -55,4 +91,14 @@ impl TopicDetails { | |
| pub fn partitions_count(&self) -> u32 { | ||
| self.inner.partitions_count | ||
| } | ||
|
|
||
| #[getter] | ||
| pub fn compression_algorithm(&self) -> String { | ||
| self.inner.compression_algorithm.to_string() | ||
| } | ||
|
|
||
| #[getter] | ||
| pub fn replication_factor(&self) -> u8 { | ||
| self.inner.replication_factor | ||
| } | ||
|
Comment on lines
+94
to
+103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add getters for the rest of the fields as well:
With docs.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same situation as the Topic getters. created_at, size, message_expiry, and max_topic_size wrap richer types (timestamp, byte size, and the IggyExpiry / MaxTopicSize tri-state enums), so they need a proper Python representation rather than one-line getters. partitions is a Vec, so exposing it also means adding a Partition class with its own getters. I'd like to handle all of these in the same follow-up to keep this PR scoped to the topic operations, and I'll cover them in the tracking issue.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add getters for the following as well:
Please also add docs to Topic and its getters in the style as shown in the review previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added getters for compression_algorithm and replication_factor since those are simple scalars. The rest wrap richer types. message_expiry and max_topic_size are tri-state enums (IggyExpiry, MaxTopicSize) that the Rust client returns without losing information, so they need a proper Python representation rather than a one-line getter. I'd like to keep this PR scoped to the topic operations and handle message_expiry, max_topic_size, size, and created_at in a follow-up. I'll open an issue to track it and link it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, please go ahead and open an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, please go ahead and open an issue