@@ -176,7 +176,8 @@ type connection struct {
176176
177177 keepAliveInterval time.Duration
178178
179- lastActive time.Time
179+ lastActive time.Time
180+ description string
180181}
181182
182183// connectionOptions defines configurations for creating connection.
@@ -189,6 +190,7 @@ type connectionOptions struct {
189190 logger log.Logger
190191 metrics * Metrics
191192 keepAliveInterval time.Duration
193+ description string
192194}
193195
194196func newConnection (opts connectionOptions ) * connection {
@@ -218,6 +220,7 @@ func newConnection(opts connectionOptions) *connection {
218220 listeners : make (map [uint64 ]ConnectionListener ),
219221 consumerHandlers : make (map [uint64 ]ConsumerHandler ),
220222 metrics : opts .metrics ,
223+ description : opts .description ,
221224 }
222225 cnx .state .Store (int32 (connectionInit ))
223226 cnx .reader = newConnectionReader (cnx )
@@ -305,7 +308,7 @@ func (c *connection) doHandshake() bool {
305308 c .cnx .SetDeadline (time .Now ().Add (c .keepAliveInterval ))
306309 cmdConnect := & pb.CommandConnect {
307310 ProtocolVersion : proto .Int32 (PulsarProtocolVersion ),
308- ClientVersion : proto .String (ClientVersionString ),
311+ ClientVersion : proto .String (c . getClientVersion () ),
309312 AuthMethodName : proto .String (c .auth .Name ()),
310313 AuthData : authData ,
311314 FeatureFlags : & pb.FeatureFlags {
@@ -346,6 +349,16 @@ func (c *connection) doHandshake() bool {
346349 return true
347350}
348351
352+ func (c * connection ) getClientVersion () string {
353+ var clientVersion string
354+ if c .description == "" {
355+ clientVersion = ClientVersionString
356+ } else {
357+ clientVersion = fmt .Sprintf ("%s-%s" , ClientVersionString , c .description )
358+ }
359+ return clientVersion
360+ }
361+
349362func (c * connection ) IsProxied () bool {
350363 return c .logicalAddr .Host != c .physicalAddr .Host
351364}
@@ -832,7 +845,7 @@ func (c *connection) handleAuthChallenge(authChallenge *pb.CommandAuthChallenge)
832845
833846 cmdAuthResponse := & pb.CommandAuthResponse {
834847 ProtocolVersion : proto .Int32 (PulsarProtocolVersion ),
835- ClientVersion : proto .String (ClientVersionString ),
848+ ClientVersion : proto .String (c . getClientVersion () ),
836849 Response : & pb.AuthData {
837850 AuthMethodName : proto .String (c .auth .Name ()),
838851 AuthData : authData ,
0 commit comments