joao-r-reis commented on code in PR #1929:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1929#discussion_r2927577103
##########
metadata.go:
##########
@@ -2049,3 +2101,319 @@ func isIdentifierChar(c byte) bool {
c == '_' ||
c == '&'
}
+
+// Handles the full schema changes including table, user type, function,
aggregate.
+func handleFullSchemaChanges(session *Session, oldKeyspaces, newKeyspaces
map[string]*KeyspaceMetadata) {
+ for _, oldKsMeta := range oldKeyspaces {
+ newKsMeta, ok := newKeyspaces[oldKsMeta.Name]
+ if !ok {
+ // Skip, KeyspaceChangeListener is already notified in
refreshSchemas()
+ continue
+ }
+
+ if session.schemaChangeListeners.TableChangeListener != nil {
Review Comment:
Example:
```
sessionInitialized := session.initialized()
notifier, supportsRefresh := session.policy.(schemaRefreshNotifier)
hasKeyspaceListener := session.schemaListeners.hasKeyspace() &&
sessionInitialized
if supportsRefresh {
notifier.schemaRefreshed(sd.getSchemaMetaForRead())
}
session.logger.Debug("Computed schema keyspace change events",
NewLogFieldInt("created_keyspaces_count", len(newKeyspaces)),
NewLogFieldInt("updated_keyspaces_count", len(updatedKeyspaces)),
NewLogFieldInt("dropped_keyspaces_count", len(droppedKeyspaces)),
)
if supportsRefresh && !hasKeyspaceListener {
return
}
notifyPolicy := func(keyspace string, change SchemaChangeType) {
if !supportsRefresh {
session.policy.KeyspaceChanged(KeyspaceUpdateEvent{Keyspace:
keyspace, Change: change})
}
}
for _, name := range newKeyspaces {
notifyPolicy(name, SchemaChangeTypeCreated)
if hasKeyspaceListener {
session.schemaListeners.OnKeyspaceCreated(OnKeyspaceCreatedEvent{Keyspace:
keyspaceMeta[name]})
}
}
for _, name := range droppedKeyspaces {
notifyPolicy(name, SchemaChangeTypeDropped)
if hasKeyspaceListener {
session.schemaListeners.OnKeyspaceDropped(OnKeyspaceDroppedEvent{Keyspace:
oldKeyspaceMeta[name]})
}
}
for _, name := range updatedKeyspaces {
notifyPolicy(name, SchemaChangeTypeUpdated)
if hasKeyspaceListener {
session.schemaListeners.OnKeyspaceUpdated(OnKeyspaceUpdatedEvent{
Old: oldKeyspaceMeta[name],
New: keyspaceMeta[name],
})
}
}
```
--
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]