[improve] PIP-411: Expose Peek Messages API to Non-Admin Clients #24088
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #24051
Main Issue: #24051
PIP: #411
Motivation
Apache Pulsar currently exposes the Peek Messages API only under the Admin API, which prevents non-admin applications from using this functionality. Some non-admin applications—such as monitoring tools or custom client applications—need to peek at messages without consuming them.
It is easier to restrict a client without admin access by denying it the admin client object. But in some cases they need the ability to peek messages which actually doesn't require admin access as peekMessages works with consume permissions..
Exposing this functionality via a new endpoint will:
Modifications
Endpoint Creation:
A new REST endpoint (e.g.,
/lookup/peek
) will be added within the Lookup API, enabling non-admin clients to access the Peek Messages functionality.LookupService:
The
LookupService
interface will be extended to include a new peekMessages method. This method will be implemented in bothHttpLookupService
andBinaryProtoLookupService
, ensuring support for peeking messages across both HTTP and binary protocol lookup mechanisms.Authorization Checks:
The new endpoint will include proper authorization checks to ensure that only permitted non-admin clients can use it.
Internal Delegation:
Requests received on the new endpoint will be internally delegated to the existing Peek Messages logic, avoiding code duplication while preserving consistent behavior.
Documentation Update:
The API documentation and reference materials will be updated to include details about the new endpoint, request parameters, response formats, and error conditions.
Verifying this change
Added unit and integration tests to validate:
Manual testing will be conducted to verify non-admin clients can access the new endpoint while admin clients continue to use the current API.
Does this pull request potentially affect one of the following parts:
This PR affects the REST endpoints (by adding a new endpoint) and binary protocol of the same.
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: cognitree#20