Skip to content

Commit

Permalink
Add command topic max producers. (streamnative/pulsar-admin-go#246) (a…
Browse files Browse the repository at this point in the history
…pache#353)

Add command topic max number of producers:

* pulsarctl topics get-max-producers [topic]
* pulsarctl topics set-max-producers [topic] -p [max]
* pulsarctl topics remove-max-producers [topic]
  • Loading branch information
limingnihao authored and tisonkun committed Aug 15, 2023
1 parent 265eb91 commit dd57f52
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pulsaradmin/pkg/pulsar/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ type Topics interface {

// RemoveMessageTTL Remove the message TTL for a topic
RemoveMessageTTL(utils.TopicName) error

// GetMaxProducers Get max number of producers for a topic
GetMaxProducers(utils.TopicName) (int, error)

// SetMaxProducers Set max number of producers for a topic
SetMaxProducers(utils.TopicName, int) error

// RemoveMaxProducers Remove max number of producers for a topic
RemoveMaxProducers(utils.TopicName) error
}

type topics struct {
Expand Down Expand Up @@ -333,3 +342,22 @@ func (t *topics) RemoveMessageTTL(topic utils.TopicName) error {
err := t.pulsar.Client.DeleteWithQueryParams(endpoint, params)
return err
}

func (t *topics) GetMaxProducers(topic utils.TopicName) (int, error) {
var maxProducers int
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "maxProducers")
err := t.pulsar.Client.Get(endpoint, &maxProducers)
return maxProducers, err
}

func (t *topics) SetMaxProducers(topic utils.TopicName, maxProducers int) error {
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "maxProducers")
err := t.pulsar.Client.Post(endpoint, &maxProducers)
return err
}

func (t *topics) RemoveMaxProducers(topic utils.TopicName) error {
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "maxProducers")
err := t.pulsar.Client.Delete(endpoint)
return err
}

0 comments on commit dd57f52

Please sign in to comment.