You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by sh...@apache.org on 2022/03/11 08:00:32 UTC
[pulsar-client-go] branch exposing-broker-metadata updated: [PIP 90] go client retrieve broker metadata
This is an automated email from the ASF dual-hosted git repository.
shoothzj pushed a commit to branch exposing-broker-metadata
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/exposing-broker-metadata by this push:
new aa26258 [PIP 90] go client retrieve broker metadata
aa26258 is described below
commit aa26258b13b27b78f90af1653aac5683749c304b
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Fri Mar 11 15:58:21 2022 +0800
[PIP 90] go client retrieve broker metadata
---
pulsar/consumer_partition.go | 13 +++++++++++--
pulsar/impl_message.go | 5 +++++
pulsar/message.go | 2 ++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/pulsar/consumer_partition.go b/pulsar/consumer_partition.go
index ea1ae4e..b06474d 100644
--- a/pulsar/consumer_partition.go
+++ b/pulsar/consumer_partition.go
@@ -603,9 +603,16 @@ func (pc *partitionConsumer) MessageReceived(response *pb.CommandMessage, header
continue
}
var messageIndex *uint64
+ var brokerPublishTime *time.Time
if brokerMetadata != nil {
- aux := brokerMetadata.GetIndex() - uint64(numMsgs) + uint64(i) + 1
- messageIndex = &aux
+ if brokerMetadata.Index != nil {
+ aux := brokerMetadata.GetIndex() - uint64(numMsgs) + uint64(i) + 1
+ messageIndex = &aux
+ }
+ if brokerMetadata.BrokerTimestamp != nil {
+ aux := timeFromUnixTimestampMillis(*brokerMetadata.BrokerTimestamp)
+ brokerPublishTime = &aux
+ }
}
// set the consumer so we know how to ack the message id
msgID.consumer = pc
@@ -626,6 +633,7 @@ func (pc *partitionConsumer) MessageReceived(response *pb.CommandMessage, header
redeliveryCount: response.GetRedeliveryCount(),
orderingKey: string(smm.OrderingKey),
index: messageIndex,
+ brokerPublishTime: brokerPublishTime,
}
} else {
msg = &message{
@@ -642,6 +650,7 @@ func (pc *partitionConsumer) MessageReceived(response *pb.CommandMessage, header
replicatedFrom: msgMeta.GetReplicatedFrom(),
redeliveryCount: response.GetRedeliveryCount(),
index: messageIndex,
+ brokerPublishTime: brokerPublishTime,
}
}
diff --git a/pulsar/impl_message.go b/pulsar/impl_message.go
index d4e3025..3216676 100644
--- a/pulsar/impl_message.go
+++ b/pulsar/impl_message.go
@@ -242,6 +242,7 @@ type message struct {
schema Schema
encryptionContext *EncryptionContext
index *uint64
+ brokerPublishTime *time.Time
}
func (msg *message) Topic() string {
@@ -304,6 +305,10 @@ func (msg *message) Index() *uint64 {
return msg.index
}
+func (msg *message) BrokerPublishTime() *time.Time {
+ return msg.brokerPublishTime
+}
+
func newAckTracker(size int) *ackTracker {
var batchIDs *big.Int
if size <= 64 {
diff --git a/pulsar/message.go b/pulsar/message.go
index f3135b1..fc1312d 100644
--- a/pulsar/message.go
+++ b/pulsar/message.go
@@ -123,6 +123,8 @@ type Message interface {
GetEncryptionContext() *EncryptionContext
Index() *uint64
+
+ BrokerPublishTime() *time.Time
}
// MessageID identifier for a particular message