-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: improve topic creation api #528
base: main
Are you sure you want to change the base?
Conversation
b44aa29
to
a82fbe9
Compare
a82fbe9
to
cd3375c
Compare
Instead of using Kafka terms, lets stay with the terminology in the Rust crate, |
fluvio/new_topic.py
Outdated
from humanfriendly import parse_timespan | ||
|
||
|
||
class TopicMode(Enum): |
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.
Instead of creating python enum, should use derive macro like here: https://pyo3.rs/v0.23.2/conversions/traits.html
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.
This new enum is only for the builder of TopicSpec, if we consider the solution without the build it's not even needed.
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.
Maybe the Compression Enum is worth, thought
Sure, but should I merge them or rename the actual Because the actual The Merge them would be something like this, what do you think? fluvio_admin = FluvioAdmin.connect()
topic_spec = (
TopicSpec.new_computed(partitions=3, replications=3, ignore=True)
.with_max_partition_size("1Gb")
.with_retention_time(3600)
.with_segment_size("10M")
.as_system_topic()
)
fluvio_admin.create_topic(self.topic, topic_spec) Another alternative is rename fluvio_admin = FluvioAdmin.connect()
topic_spec = (
TopicSpecBuilder.create()
.with_partitions(3)
.with_replications(3)
.with_max_partition_size("1Gb")
.with_retention_time(3600)
.with_segment_size("10M")
.as_system_topic()
.build()
)
fluvio_admin.create_topic(self.topic, topic_spec) |
The first one is good w/ TopicSpec. If you can do it with the direct annotations in lib.rs PyO3 or appropriate module use that. There are a lot of instances in the fluvio python client that rename some FluvioStruct to _FluvioStruct internally, so a pythonic FluvioStruct can be supplied to the interpreter too, but it's extra layers that should have some interface value if thats done. (there are legacy portions of the code that does it unecessarily) |
Oh we shoudl also remove the required partitions, replications, and bool arguments and just support |
I think that would need a larger refactor on fluvio side. IIRC, we don't have the feature of adding replicas to an already existent Topic. In the builder it was easier because it's calling wdyt? |
This is only more featured topic create for the python client, if the topic already exists the create should return an error. |
aed561b
to
2db7e99
Compare
self.inner.set_compression_type(CompressionAlgorithm::Zstd); | ||
} | ||
self.inner.set_compression_type(CompressionAlgorithm::Any); | ||
} |
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.
This should probably return an error if not recognized, or it could accept a compression type enum
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 changed to return result, and an error for this case.
The support for enum that are not tag unions does not seem great in pyo3, it's also not automatically typed, so no benefits at all.
2db7e99
to
c5a89b6
Compare
Simple (1 partition and 1 replica):
or
Advanced:
I am usingNewTopic
only because kafka-python also uses a class calledNewTopic