raj14243 commented on code in PR #1926:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1926#discussion_r2756720770
##########
events.go:
##########
@@ -133,27 +133,42 @@ func (s *Session) handleEvent(framer *framer) {
}
func (s *Session) handleSchemaEvent(frames []frame) {
- // TODO: debounce events
+
+ if len(frames) > 0 {
+ s.control.awaitSchemaAgreement()
+ }
+
+ // Collect unique keyspaces that need schema refresh
+ keyspacesToRefresh := make(map[string]struct{})
+
for _, frame := range frames {
switch f := frame.(type) {
case *schemaChangeKeyspace:
s.schemaDescriber.clearSchema(f.keyspace)
- s.handleKeyspaceChange(f.keyspace, f.change)
+ s.policy.KeyspaceChanged(KeyspaceUpdateEvent{Keyspace:
f.keyspace, Change: f.change})
+ keyspacesToRefresh[f.keyspace] = struct{}{}
case *schemaChangeTable:
s.schemaDescriber.clearSchema(f.keyspace)
+ keyspacesToRefresh[f.keyspace] = struct{}{}
case *schemaChangeAggregate:
s.schemaDescriber.clearSchema(f.keyspace)
+ keyspacesToRefresh[f.keyspace] = struct{}{}
case *schemaChangeFunction:
s.schemaDescriber.clearSchema(f.keyspace)
+ keyspacesToRefresh[f.keyspace] = struct{}{}
case *schemaChangeType:
s.schemaDescriber.clearSchema(f.keyspace)
+ keyspacesToRefresh[f.keyspace] = struct{}{}
}
}
-}
-func (s *Session) handleKeyspaceChange(keyspace, change string) {
- s.control.awaitSchemaAgreement()
- s.policy.KeyspaceChanged(KeyspaceUpdateEvent{Keyspace: keyspace,
Change: change})
+ for keyspace := range keyspacesToRefresh {
+ if _, err := s.schemaDescriber.getSchema(keyspace); err != nil {
Review Comment:
Aligned on next steps
https://the-asf.slack.com/archives/C05LPRVNZV1/p1768514415652969
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]