cqlclient.go ×11

Frontier kind: Code frontier

unlabeled · c_ccdc33b52a79

7 tests · 2292 LOC · 112 files · introduces 0 tests · 65 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges65 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
375 ranges2292 lines · 112 files · Browse complete extent
All tests (intent)
7 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 65 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/tools/cassandra/cqlclient.go 62 introduced LOC · 11 ranges

Open complete file

82
83 // newCQLClient returns a new instance of CQLClient
84 > func newCQLClient(cfg *CQLClientConfig, logger log.Logger) (*cqlClient, error) { cqlclient.go
85 > var err error
86 >
87 > cassandraConfig := cfg.toCassandraConfig()
88 >
89 > logger.Info("Validating connection to cassandra cluster.")
90 > session, err := commongocql.NewSession(
91 > func() (*gocql.ClusterConfig, error) {
92 > return commongocql.NewCassandraCluster(*cassandraConfig, resolver.NewNoopResolver())
93 > },
94 logger,
95 metrics.NoopMetricsHandler,
96 )
97 > if err != nil { cqlclient.go
98 logger.Error("Connection validation failed.", tag.Error(err))
99 return nil, err
100 }
101 > logger.Info("Connection validation succeeded.") cqlclient.go
102 >
103 > return &cqlClient{
104 > keyspace: cfg.Keyspace,
105 > nReplicas: cfg.numReplicas,
106 > datacenter: cfg.Datacenter,
107 > timeout: time.Duration(cfg.Timeout) * time.Second,
108 > session: session,
109 > logger: logger,
110 > }, nil
111 }
112
113 > func (cfg *CQLClientConfig) toCassandraConfig() *config.Cassandra { cqlclient.go
114 > cassandraConfig := config.Cassandra{
115 > Hosts: cfg.Hosts,
116 > Port: cfg.Port,
117 > User: cfg.User,
118 > Password: cfg.Password,
119 > AllowedAuthenticators: cfg.AllowedAuthenticators,
120 > Keyspace: cfg.Keyspace,
121 > TLS: cfg.TLS,
122 > Datacenter: cfg.Datacenter,
123 > DisableInitialHostLookup: cfg.DisableInitialHostLookup,
124 > Consistency: &config.CassandraStoreConsistency{
125 > Default: &config.CassandraConsistencySettings{
126 > Consistency: cfg.Consistency,
127 > },
128 > },
129 > AddressTranslator: cfg.AddressTranslator,
130 > ConnectTimeout: time.Duration(cfg.Timeout) * time.Second,
131 > }
132 >
133 > return &cassandraConfig
134 > }
135
136 func (client *cqlClient) CreateDatabase(name string) error {
143
144 // createKeyspace creates a cassandra Keyspace if it doesn't exist
145 > func (client *cqlClient) createKeyspace(name string) error { cqlclient.go
146 > if client.datacenter != "" {
147 client.logger.Info(fmt.Sprintf("Creating Keyspace %v using NetworkTopologyStrategy in Datacenter %v with RF=%v.", name, client.datacenter, client.nReplicas))
148 return client.Exec(fmt.Sprintf(createKeyspaceNetworkTopologyCQL, name, client.datacenter, client.nReplicas))
149 }
150 > client.logger.Info(fmt.Sprintf("Creating Keyspace %v using SimpleStrategy with RF=%v.", name, client.nReplicas)) cqlclient.go
151 > return client.Exec(fmt.Sprintf(createKeyspaceCQL, name, client.nReplicas))
152 }
153
154 // dropKeyspace drops a Keyspace
155 > func (client *cqlClient) dropKeyspace(name string) error { cqlclient.go
156 > return client.Exec(fmt.Sprintf("DROP KEYSPACE IF EXISTS %v", name))
157 > }
158
159 func (client *cqlClient) DropAllTables() error {
201
202 // Exec executes a cql statement
203 > func (client *cqlClient) Exec(stmt string, args ...any) error { cqlclient.go
204 > if err := client.session.Query(stmt, args...).Exec(); err != nil {
205 return err
206 }
207 > return client.waitSchemaAgreement() cqlclient.go
208 }
209
210 // Close closes the cql client
211 > func (client *cqlClient) Close() { cqlclient.go
212 > if client.session != nil {
213 > client.session.Close()
214 > }
215 }
216
294
295 // waitSchemaAgreement wait for schema change agreements
296 > func (client *cqlClient) waitSchemaAgreement() error { cqlclient.go
297 > ctx, cancel := context.WithTimeout(context.Background(), client.timeout)
298 > defer cancel()
299 > return client.session.AwaitSchemaAgreement(ctx)
300 > }
301
302 // Type gives the type of db
go.temporal.io/server/common/persistence/nosql/nosqlplugin/cassandra/gocql/session.go 3 introduced LOC · 2 ranges

Open complete file

157 func (s *session) AwaitSchemaAgreement(
158 ctx context.Context,
159 > ) (retError error) { session.go
160 > defer func() { s.handleError(retError) }()
161
162 > return s.Value.Load().(*gocql.Session).AwaitSchemaAgreement(ctx) session.go
163 }
164