08abhinav opened a new pull request, #4720:
URL: https://github.com/apache/iggy/pull/4720

   ## Which issue does this PR address?
   
   Closes #4697 
   
   ## Rationale
   
   The Rust, Java and Node examples include a multi-tenant example, but the 
Python examples had none. This adds one using only SDK calls that already exist 
(`create_user` with `permissions`, `update_permissions`, `Permissions`, 
`StreamPermissions`).
   
   ## What changed?
   
   The Python examples had no demonstration of isolating tenants on one server. 
This adds `examples/python/multi-tenant/` with `producer.py`, `consumer.py` and 
a shared `common.py`. The producer creates a stream, topic and restricted user 
per tenant (count from `TENANTS_COUNT`, default 3), then sends messages as each 
tenant after checking that other tenants' streams are refused. The consumer 
reads one tenant's stream as that tenant (`--tenant-id`). A "Multi-Tenant" 
section is added to `examples/python/README.md`, and the new directory is added 
to the pyrefly `search-path` in `pyproject.toml`.
   
   ## Local Execution
   
   - Passed (`uv sync`, fresh server, `uv run multi-tenant/producer.py`, then 
`uv run multi-tenant/consumer.py --tenant-id 2`: only that tenant's messages 
were read)
   - Also tested a second producer run, `TENANTS_COUNT=5`, an invalid 
`--tenant-id`, and the negative case (temporarily granting global 
`read_streams`, which made the access check fail as expected)
   - `ruff check`, `ruff format` and `pyrefly check` passed
   - Pre-commit hooks ran (`prek`)
   
   ## AI Usage
   
   AI was used to assist with repository exploration, implementation, and 
documentation.
   
   - Development assistance: Reviewed existing PHP and Rust examples while 
implementing the producer.
   - I reviewed the changes and can explain the implementation and its design 
decisions.


-- 
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]

Reply via email to