From 6b25456998248024d3f426754a18bdd4d7a0cdcf Mon Sep 17 00:00:00 2001 From: sylwiaszunejko Date: Fri, 29 Nov 2024 14:49:42 +0100 Subject: [PATCH] Rename schemaDescriber to metadataDescriber --- conn.go | 2 +- events.go | 14 +++++++------- host_source.go | 2 +- metadata_scylla.go | 24 ++++++++++++------------ policies.go | 2 +- recreate_test.go | 2 +- schema_queries_test.go | 4 ++-- session.go | 12 ++++++------ 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/conn.go b/conn.go index ec0846da1..26757f509 100644 --- a/conn.go +++ b/conn.go @@ -1522,7 +1522,7 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter { tablet.keyspaceName = qry.routingInfo.keyspace tablet.tableName = qry.routingInfo.table - c.session.schemaDescriber.addTablet(&tablet) + c.session.metadataDescriber.addTablet(&tablet) } } diff --git a/events.go b/events.go index 200c003df..54ca5f4c5 100644 --- a/events.go +++ b/events.go @@ -110,17 +110,17 @@ func (s *Session) handleSchemaEvent(frames []frame) { for _, frame := range frames { switch f := frame.(type) { case *schemaChangeKeyspace: - s.schemaDescriber.clearSchema(f.keyspace) + s.metadataDescriber.clearSchema(f.keyspace) s.handleKeyspaceChange(f.keyspace, f.change) case *schemaChangeTable: - s.schemaDescriber.clearSchema(f.keyspace) + s.metadataDescriber.clearSchema(f.keyspace) s.handleTableChange(f.keyspace, f.object, f.change) case *schemaChangeAggregate: - s.schemaDescriber.clearSchema(f.keyspace) + s.metadataDescriber.clearSchema(f.keyspace) case *schemaChangeFunction: - s.schemaDescriber.clearSchema(f.keyspace) + s.metadataDescriber.clearSchema(f.keyspace) case *schemaChangeType: - s.schemaDescriber.clearSchema(f.keyspace) + s.metadataDescriber.clearSchema(f.keyspace) } } } @@ -128,14 +128,14 @@ func (s *Session) handleSchemaEvent(frames []frame) { func (s *Session) handleKeyspaceChange(keyspace, change string) { s.control.awaitSchemaAgreement() if change == "DROPPED" || change == "UPDATED" { - s.schemaDescriber.removeTabletsWithKeyspace(keyspace) + s.metadataDescriber.removeTabletsWithKeyspace(keyspace) } s.policy.KeyspaceChanged(KeyspaceUpdateEvent{Keyspace: keyspace, Change: change}) } func (s *Session) handleTableChange(keyspace, table, change string) { if change == "DROPPED" || change == "UPDATED" { - s.schemaDescriber.removeTabletsWithTable(keyspace, table) + s.metadataDescriber.removeTabletsWithTable(keyspace, table) } } diff --git a/host_source.go b/host_source.go index b71ac3139..9b835e3a2 100644 --- a/host_source.go +++ b/host_source.go @@ -877,7 +877,7 @@ func refreshRing(r *ringDescriber) error { } for _, host := range prevHosts { - r.session.schemaDescriber.removeTabletsWithHost(host) + r.session.metadataDescriber.removeTabletsWithHost(host) r.session.removeHost(host) } diff --git a/metadata_scylla.go b/metadata_scylla.go index d2d95472a..13b5e60e3 100644 --- a/metadata_scylla.go +++ b/metadata_scylla.go @@ -277,7 +277,7 @@ type Metadata struct { } // queries the cluster for schema information for a specific keyspace and for tablets -type schemaDescriber struct { +type metadataDescriber struct { session *Session mu sync.Mutex @@ -286,8 +286,8 @@ type schemaDescriber struct { // creates a session bound schema describer which will query and cache // keyspace metadata and tablets metadata -func newSchemaDescriber(session *Session) *schemaDescriber { - return &schemaDescriber{ +func newMetadataDescriber(session *Session) *metadataDescriber { + return &metadataDescriber{ session: session, metadata: &Metadata{}, } @@ -295,7 +295,7 @@ func newSchemaDescriber(session *Session) *schemaDescriber { // returns the cached KeyspaceMetadata held by the describer for the named // keyspace. -func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) { +func (s *metadataDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) { s.mu.Lock() defer s.mu.Unlock() @@ -316,21 +316,21 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err return metadata, nil } -func (s *schemaDescriber) setTablets(tablets TabletInfoList) { +func (s *metadataDescriber) setTablets(tablets TabletInfoList) { s.mu.Lock() defer s.mu.Unlock() s.metadata.tabletsMetadata.set(tablets) } -func (s *schemaDescriber) getTablets() TabletInfoList { +func (s *metadataDescriber) getTablets() TabletInfoList { s.mu.Lock() defer s.mu.Unlock() return s.metadata.tabletsMetadata.get() } -func (s *schemaDescriber) addTablet(tablet *TabletInfo) error { +func (s *metadataDescriber) addTablet(tablet *TabletInfo) error { tablets := s.getTablets() tablets = tablets.addTabletToTabletsList(tablet) @@ -339,7 +339,7 @@ func (s *schemaDescriber) addTablet(tablet *TabletInfo) error { return nil } -func (s *schemaDescriber) removeTabletsWithHost(host *HostInfo) error { +func (s *metadataDescriber) removeTabletsWithHost(host *HostInfo) error { tablets := s.getTablets() tablets = tablets.removeTabletsWithHostFromTabletsList(host) @@ -348,7 +348,7 @@ func (s *schemaDescriber) removeTabletsWithHost(host *HostInfo) error { return nil } -func (s *schemaDescriber) removeTabletsWithKeyspace(keyspace string) error { +func (s *metadataDescriber) removeTabletsWithKeyspace(keyspace string) error { tablets := s.getTablets() tablets = tablets.removeTabletsWithKeyspaceFromTabletsList(keyspace) @@ -357,7 +357,7 @@ func (s *schemaDescriber) removeTabletsWithKeyspace(keyspace string) error { return nil } -func (s *schemaDescriber) removeTabletsWithTable(keyspace string, table string) error { +func (s *metadataDescriber) removeTabletsWithTable(keyspace string, table string) error { tablets := s.getTablets() tablets = tablets.removeTabletsWithTableFromTabletsList(keyspace, table) @@ -367,7 +367,7 @@ func (s *schemaDescriber) removeTabletsWithTable(keyspace string, table string) } // clears the already cached keyspace metadata -func (s *schemaDescriber) clearSchema(keyspaceName string) { +func (s *metadataDescriber) clearSchema(keyspaceName string) { s.mu.Lock() defer s.mu.Unlock() @@ -376,7 +376,7 @@ func (s *schemaDescriber) clearSchema(keyspaceName string) { // forcibly updates the current KeyspaceMetadata held by the schema describer // for a given named keyspace. -func (s *schemaDescriber) refreshSchema(keyspaceName string) error { +func (s *metadataDescriber) refreshSchema(keyspaceName string) error { var err error // query the system keyspace for schema data diff --git a/policies.go b/policies.go index 955d2ecc8..0fec485b4 100644 --- a/policies.go +++ b/policies.go @@ -663,7 +663,7 @@ func (t *tokenAwareHostPolicy) Pick(qry ExecutableQuery) NextHost { var replicas []*HostInfo if session := qry.GetSession(); session != nil && session.tabletsRoutingV1 { - tablets := session.schemaDescriber.getTablets() + tablets := session.metadataDescriber.getTablets() // Search for tablets with Keyspace and Table from the Query l, r := tablets.findTablets(qry.Keyspace(), qry.Table()) diff --git a/recreate_test.go b/recreate_test.go index 88bbe0f84..e21ce5bad 100644 --- a/recreate_test.go +++ b/recreate_test.go @@ -143,7 +143,7 @@ func TestRecreateSchema(t *testing.T) { // Exec dumped queries to check if they are CQL-correct cleanup(t, session, test.Keyspace) - session.schemaDescriber.clearSchema(test.Keyspace) + session.metadataDescriber.clearSchema(test.Keyspace) for _, q := range trimQueries(strings.Split(dump, ";")) { qr := session.Query(q, nil) diff --git a/schema_queries_test.go b/schema_queries_test.go index 62f10f02d..9281d2328 100644 --- a/schema_queries_test.go +++ b/schema_queries_test.go @@ -16,9 +16,9 @@ func TestSchemaQueries(t *testing.T) { session := createSessionFromCluster(cluster, t) defer session.Close() - keyspaceMetadata, err := session.schemaDescriber.getSchema("gocql_test") + keyspaceMetadata, err := session.metadataDescriber.getSchema("gocql_test") if err != nil { t.Fatal("unable to get keyspace metadata for keyspace: ", err) } - assertTrue(t, "keyspace present in schemaDescriber", keyspaceMetadata.Name == "gocql_test") + assertTrue(t, "keyspace present in metadataDescriber", keyspaceMetadata.Name == "gocql_test") } diff --git a/session.go b/session.go index bc09fa4f6..9830e736f 100644 --- a/session.go +++ b/session.go @@ -35,7 +35,7 @@ type Session struct { pageSize int prefetch float64 routingKeyInfoCache routingKeyInfoLRU - schemaDescriber *schemaDescriber + metadataDescriber *metadataDescriber trace Tracer queryObserver QueryObserver batchObserver BatchObserver @@ -144,7 +144,7 @@ func NewSession(cfg ClusterConfig) (*Session, error) { } }() - s.schemaDescriber = newSchemaDescriber(s) + s.metadataDescriber = newMetadataDescriber(s) s.nodeEvents = newEventDebouncer("NodeEvents", s.handleNodeEvent, s.logger) s.schemaEvents = newEventDebouncer("SchemaEvents", s.handleSchemaEvent, s.logger) @@ -277,7 +277,7 @@ func (s *Session) init() error { if s.tabletsRoutingV1 { tablets := TabletInfoList{} - s.schemaDescriber.setTablets(tablets) + s.metadataDescriber.setTablets(tablets) } } } @@ -603,7 +603,7 @@ func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) { return nil, ErrNoKeyspace } - return s.schemaDescriber.getSchema(keyspace) + return s.metadataDescriber.getSchema(keyspace) } // TabletsMetadata returns the metadata about tablets @@ -615,7 +615,7 @@ func (s *Session) TabletsMetadata() (TabletInfoList, error) { return nil, ErrTabletsNotUsed } - return s.schemaDescriber.getTablets(), nil + return s.metadataDescriber.getTablets(), nil } func (s *Session) getConn() *Conn { @@ -637,7 +637,7 @@ func (s *Session) getConn() *Conn { } func (s *Session) getTablets() TabletInfoList { - return s.schemaDescriber.getTablets() + return s.metadataDescriber.getTablets() } // returns routing key indexes and type info