feat: align topics level policies admin apis to java restful apis#1398
Merged
Conversation
…te, max consumers, message size, subscriptions, schema validation, deduplication, replicator dispatch rate, offload policies, auto subscription creation, and schema compatibility strategy
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive topic-level policy management APIs to the Pulsar Go admin client to align with the Java REST APIs. The implementation provides feature parity for managing topic policies programmatically through Go applications.
Key changes include:
- Addition of 9 new topic policy API categories with get/set/remove operations
- New data structures for offload policies and auto subscription creation configuration
- Enhanced delayed delivery data structure with optional maximum delay limits
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pulsaradmin/pkg/utils/offload_policies.go | Defines OffloadPolicies struct with S3 and general offload configuration fields |
| pulsaradmin/pkg/utils/data.go | Enhances DelayedDeliveryData with optional MaxDelayInMillis field and helper functions |
| pulsaradmin/pkg/utils/auto_subscription_creation.go | Defines AutoSubscriptionCreationOverride struct for managing auto subscription settings |
| pulsaradmin/pkg/admin/topic.go | Implements 27 new topic policy management methods across 9 API categories |
Comments suppressed due to low confidence (1)
pulsaradmin/pkg/utils/offload_policies.go:30
- Inconsistent field naming: The struct field is named 'S3ManagedLedgerOffloadCredentialID' but the JSON tag uses 'Id' instead of 'ID'. This creates inconsistency between Go naming conventions and the JSON representation.
S3ManagedLedgerOffloadCredentialID string `json:"s3ManagedLedgerOffloadCredentialId,omitempty"`
Member
|
Could you please add the relevant unit tests? |
Contributor
Author
addressed with latest commits |
crossoverJie
approved these changes
Jul 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…te, max consumers, message size, subscriptions, schema validation, deduplication, replicator dispatch rate, offload policies, auto subscription creation, and schema compatibility strategy
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
The Pulsar Go client's admin APIs for topic-level policies were incomplete and not aligned with the Java client's RESTful APIs. This inconsistency made it difficult for users who work with both Java and Go clients to have a unified experience when managing topic-level policies programmatically.
Currently, many essential topic-level policy management features available in the Java admin client are missing in the Go client, limiting the ability to fully manage Pulsar topics through Go applications. This includes policies for:
By aligning these APIs with the Java implementation, we ensure feature parity and provide Go developers with the same administrative capabilities.
Modifications
This PR adds comprehensive topic-level policy management APIs to align with the Java admin client. The following APIs have been implemented:
New Topic Policy APIs Added:
Max Consumers Policy
GetMaxConsumers(topic string) (int, error)SetMaxConsumers(topic string, maxConsumers int) errorRemoveMaxConsumers(topic string) errorMax Message Size Policy
GetMaxMessageSize(topic string) (int, error)SetMaxMessageSize(topic string, maxMessageSize int) errorRemoveMaxMessageSize(topic string) errorSubscription Management
GetSubscriptionDispatchRate(topic string) (*DispatchRate, error)SetSubscriptionDispatchRate(topic string, dispatchRate DispatchRate) errorRemoveSubscriptionDispatchRate(topic string) errorSchema Validation Policy
GetSchemaValidationEnforced(topic string) (bool, error)SetSchemaValidationEnforced(topic string, enforced bool) errorDeduplication Policy
GetDeduplicationStatus(topic string) (bool, error)SetDeduplicationStatus(topic string, enabled bool) errorRemoveDeduplicationStatus(topic string) errorReplicator Dispatch Rate
GetReplicatorDispatchRate(topic string) (*DispatchRate, error)SetReplicatorDispatchRate(topic string, dispatchRate DispatchRate) errorRemoveReplicatorDispatchRate(topic string) errorOffload Policies
GetOffloadPolicies(topic string) (*OffloadPolicies, error)SetOffloadPolicies(topic string, policies OffloadPolicies) errorRemoveOffloadPolicies(topic string) errorAuto Subscription Creation
GetAutoSubscriptionCreation(topic string) (*AutoSubscriptionCreationOverride, error)SetAutoSubscriptionCreation(topic string, config AutoSubscriptionCreationOverride) errorRemoveAutoSubscriptionCreation(topic string) errorSchema Compatibility Strategy
GetSchemaCompatibilityStrategy(topic string) (SchemaCompatibilityStrategy, error)SetSchemaCompatibilityStrategy(topic string, strategy SchemaCompatibilityStrategy) errorRemoveSchemaCompatibilityStrategy(topic string) errorVerifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation