close
Skip to content

feat(example): basic example for python sdk#2118

Merged
spetz merged 3 commits into
apache:masterfrom
changhc:1889-basic-example
Aug 25, 2025
Merged

feat(example): basic example for python sdk#2118
spetz merged 3 commits into
apache:masterfrom
changhc:1889-basic-example

Conversation

@changhc
Copy link
Copy Markdown
Contributor

@changhc changhc commented Aug 19, 2025

Description

Created a basic example for the python SDK that sort of matches examples/rust/basic. It demonstrates how to configure clients using connection strings. Overall it's pretty similar to the getting-started example.

This example is a bit different from examples/rust/basic because the rust client builder struct and config types are not exposed through the python SDK as explained in #2110.

Testing

  • Ran the examples locally
  • ruff check --select I .

@cstruct
Copy link
Copy Markdown
Contributor

cstruct commented Aug 19, 2025

I'm wondering if for most use cases we should encourage the use of consumer groups? My gut feeling is that the consumer group API is the right fit for most use cases. It would not be aligned with the Rust examples though so maybe that is a broader discussion of what abstraction level is right to introduce most users to? What do you think?

@changhc
Copy link
Copy Markdown
Contributor Author

changhc commented Aug 19, 2025

I'm okay with that. The rust basic example actually allows users to run either a regular consumer or a consumer group. Because of all the shared functions in the rust examples, it's kind of difficult to completely align with those examples, and thus I think it's okay if we want to add options to the python examples (this basic example specifically) to allow users to chose which kind of consumer to use. For now demonstrating how to create a consumer group with the SDK should be sufficient. What would help more in my opinion is to explain these two types of consumers clearly in the documentation.

I'll add the consumer group as an option and we see how it goes?

Copy link
Copy Markdown
Contributor

@hubcio hubcio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general i'm fine with this approach but there is one missing thing: could you prepare a script, similar to scripts/run-go-examples-from-readme.sh or scripts/run-rust-examples-from-readme.sh where you'll explicitly test those examples?

Comment thread examples/python/basic/consumer.py
@changhc
Copy link
Copy Markdown
Contributor Author

changhc commented Aug 20, 2025

Yes. My plan is to reuse foreign/python/scripts/test.sh and I do have a local implementation. I'll set up the test properly after #2101 is merged to avoid conflicts.

@changhc changhc marked this pull request as ready for review August 24, 2025 23:05
@changhc
Copy link
Copy Markdown
Contributor Author

changhc commented Aug 24, 2025

I've decided to keep the current polling consumer for now. I tried out the consumer group and I don't think the python API is actually ready to be used. Apart from some obvious issues, usability is horrible and we definitely need to redesign this.

@spetz spetz merged commit 9803fda into apache:master Aug 25, 2025
17 checks passed
hageshiame pushed a commit to hageshiame/iggy that referenced this pull request Nov 7, 2025
Created a basic example for the python SDK that sort of matches`examples/rust/basic`.
It demonstrates how to configure clients using connection strings.
Overall it's pretty similar to the `getting-started` example.

This example is a bit different from `examples/rust/basic` because the Rust client builder
struct and config types are not exposed through the python SDK as explained in apache#2110.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants