From 2b3a6e6cdef3df5369df9cd2d389e2da400da6f3 Mon Sep 17 00:00:00 2001 From: Neil Twigg Date: Wed, 27 Nov 2024 16:00:25 +0000 Subject: [PATCH] Don't include unnecessary `ClientInfo` fields in stream and consumer assignments Signed-off-by: Neil Twigg --- server/events.go | 9 +++++++++ server/jetstream_cluster.go | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/events.go b/server/events.go index ff5a8dbc35..7846b2d4ab 100644 --- a/server/events.go +++ b/server/events.go @@ -327,6 +327,15 @@ type ClientInfo struct { Nonce string `json:"nonce,omitempty"` } +// forAssignmentSnap returns the minimum amount of ClientInfo we need for assignment snapshots. +func (ci *ClientInfo) forAssignmentSnap() *ClientInfo { + return &ClientInfo{ + Account: ci.Account, + Service: ci.Service, + Cluster: ci.Cluster, + } +} + // ServerStats hold various statistics that we will periodically send out. type ServerStats struct { Start time.Time `json:"start"` diff --git a/server/jetstream_cluster.go b/server/jetstream_cluster.go index d4684d6e84..a0e7cb585a 100644 --- a/server/jetstream_cluster.go +++ b/server/jetstream_cluster.go @@ -1542,7 +1542,7 @@ func (js *jetStream) metaSnapshot() []byte { for _, asa := range cc.streams { for _, sa := range asa { wsa := writeableStreamAssignment{ - Client: sa.Client, + Client: sa.Client.forAssignmentSnap(), Created: sa.Created, Config: sa.Config, Group: sa.Group, @@ -1555,7 +1555,9 @@ func (js *jetStream) metaSnapshot() []byte { if ca.pending { continue } - wsa.Consumers = append(wsa.Consumers, ca) + cca := *ca + cca.Client = cca.Client.forAssignmentSnap() + wsa.Consumers = append(wsa.Consumers, &cca) nca++ } streams = append(streams, wsa)