Skip to content

Commit

Permalink
Don't include unnecessary ClientInfo fields in metalayer snapshots (#…
Browse files Browse the repository at this point in the history
…6185)

This should reduce the size of metalayer snapshots quite significantly
by only including the `Account`, `Service` and `Cluster` fields from the
`ClientInfo`, as those are the only ones that are relevant from a
snapshot.

Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
derekcollison authored Nov 27, 2024
2 parents 41a2db4 + 2b3a6e6 commit cfaad68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions server/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 4 additions & 2 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit cfaad68

Please sign in to comment.