Skip to content

Commit

Permalink
Remove JWT & alternates from $JS.EVENT.ADVISORY.API and stream snap…
Browse files Browse the repository at this point in the history
…shot/restore advisories (#6338)

Otherwise these advisories can end up very large and take more CPU time
to encode.

Signed-off-by: Neil Twigg <[email protected]>
  • Loading branch information
derekcollison authored Jan 7, 2025
2 parents fdd16d8 + fcb3ae1 commit 5354834
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions server/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ func (ci *ClientInfo) forProposal() *ClientInfo {
return &cci
}

// forAdvisory returns the minimum amount of ClientInfo we need for JS advisory events.
func (ci *ClientInfo) forAdvisory() *ClientInfo {
if ci == nil {
return nil
}
cci := *ci
cci.Jwt = _EMPTY_
cci.Alternates = nil
return &cci
}

// ServerStats hold various statistics that we will periodically send out.
type ServerStats struct {
Start time.Time `json:"start"`
Expand Down
10 changes: 5 additions & 5 deletions server/jetstream_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3833,7 +3833,7 @@ func (s *Server) processStreamRestore(ci *ClientInfo, acc *Account, cfg *StreamC
Time: start,
},
Stream: streamName,
Client: ci,
Client: ci.forAdvisory(),
Domain: domain,
})

Expand Down Expand Up @@ -3965,7 +3965,7 @@ func (s *Server) processStreamRestore(ci *ClientInfo, acc *Account, cfg *StreamC
Start: start,
End: end,
Bytes: int64(total),
Client: ci,
Client: ci.forAdvisory(),
Domain: domain,
})

Expand Down Expand Up @@ -4099,7 +4099,7 @@ func (s *Server) jsStreamSnapshotRequest(sub *subscription, c *client, _ *Accoun
},
Stream: mset.name(),
State: sr.State,
Client: ci,
Client: ci.forAdvisory(),
Domain: s.getOpts().JetStreamDomain,
})

Expand All @@ -4117,7 +4117,7 @@ func (s *Server) jsStreamSnapshotRequest(sub *subscription, c *client, _ *Accoun
Stream: mset.name(),
Start: start,
End: end,
Client: ci,
Client: ci.forAdvisory(),
Domain: s.getOpts().JetStreamDomain,
})

Expand Down Expand Up @@ -5065,7 +5065,7 @@ func (s *Server) sendJetStreamAPIAuditAdvisory(ci *ClientInfo, acc *Account, sub
Time: time.Now().UTC(),
},
Server: s.Name(),
Client: ci,
Client: ci.forAdvisory(),
Subject: subject,
Request: request,
Response: response,
Expand Down

0 comments on commit 5354834

Please sign in to comment.