Skip to content

Commit

Permalink
[Improve] Implement GetTopicAutoCreation
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Jan 5, 2024
1 parent 3a1a766 commit 1258e47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pulsaradmin/pkg/admin/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ type Namespaces interface {
// RemoveBacklogQuota removes a backlog quota policy from a namespace
RemoveBacklogQuota(namespace string) error

// GetTopicAutoCreation returns the topic auto-creation config for a namespace
GetTopicAutoCreation(namespace utils.NameSpaceName) (*utils.TopicAutoCreationConfig, error)

// SetTopicAutoCreation sets topic auto-creation config for a namespace, overriding broker settings
SetTopicAutoCreation(namespace utils.NameSpaceName, config utils.TopicAutoCreationConfig) error

Expand Down Expand Up @@ -445,6 +448,13 @@ func (n *namespaces) RemoveBacklogQuota(namespace string) error {
return n.pulsar.Client.DeleteWithQueryParams(endpoint, params)
}

func (n *namespaces) GetTopicAutoCreation(namespace utils.NameSpaceName) (*utils.TopicAutoCreationConfig, error) {
var topicAutoCreation utils.TopicAutoCreationConfig
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), "autoTopicCreation")
err := n.pulsar.Client.Get(endpoint, &topicAutoCreation)
return &topicAutoCreation, err
}

func (n *namespaces) SetTopicAutoCreation(namespace utils.NameSpaceName, config utils.TopicAutoCreationConfig) error {
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), "autoTopicCreation")
return n.pulsar.Client.Post(endpoint, &config)
Expand Down
2 changes: 1 addition & 1 deletion pulsaradmin/pkg/utils/topic_auto_creation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ package utils
type TopicAutoCreationConfig struct {
Allow bool `json:"allowAutoTopicCreation"`
Type TopicType `json:"topicType"`
Partitions int `json:"defaultNumPartitions"`
Partitions *int `json:"defaultNumPartitions"`
}

0 comments on commit 1258e47

Please sign in to comment.