Skip to content

Commit

Permalink
feat: add GetMessageID api (streamnative/pulsar-admin-go#28)
Browse files Browse the repository at this point in the history
add GetMessageID api

Co-authored-by: 辛传涛 <xinchuantao@bilibili.com>
Co-authored-by: Fushu Wang <fswang@streamnative.io>
  • Loading branch information
3 people authored and tisonkun committed Aug 16, 2023
1 parent 3b2df30 commit 521ee5d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pulsaradmin/pkg/admin/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type Topics interface {
// GetLastMessageID returns the last commit message Id of a topic
GetLastMessageID(utils.TopicName) (utils.MessageID, error)

// GetMessageID returns the message Id by timestamp(ms) of a topic
GetMessageID(utils.TopicName, int64) (utils.MessageID, error)

// GetStats returns the stats for the topic
// All the rates are computed over a 1 minute window and are relative the last completed 1 minute period
GetStats(utils.TopicName) (utils.TopicStats, error)
Expand Down Expand Up @@ -377,6 +380,13 @@ func (t *topics) GetLastMessageID(topic utils.TopicName) (utils.MessageID, error
return messageID, err
}

func (t *topics) GetMessageID(topic utils.TopicName, timestamp int64) (utils.MessageID, error) {
var messageID utils.MessageID
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "messageid", strconv.FormatInt(timestamp, 10))
err := t.pulsar.Client.Get(endpoint, &messageID)
return messageID, err
}

func (t *topics) GetStats(topic utils.TopicName) (utils.TopicStats, error) {
var stats utils.TopicStats
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "stats")
Expand Down

0 comments on commit 521ee5d

Please sign in to comment.