go.temporal.io/server/tools/cassandra/main.go

273 LOC · 165 covered · 108 uncovered · 10 ranges · 14 concepts · 7 introducers · 7 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/tools/cassandra/cqlclient.go · 305 LOCcassandra/cqlclient.gogo.temporal.io/server/tools/cassandra/handler.go · 233 LOCcassandra/handler.gogo.temporal.io/server/tools/cassandra/update_task_tests.go · 39 LOCcassandra/update_task_te…update_task_tests.go ×1 · 6 introduced LOCupdate_task_tests.go ×1cqlclient.go ×4 · 17 introduced LOCcqlclient.go ×4handler.go ×4 · 18 introduced LOChandler.go ×4handler.go ×1 · 8 introduced LOChandler.go ×1schema_version_reader.go ×4 · 77 introduced LOCschema_version_reader.go…handler.go ×4 · 12 introduced LOChandler.go ×4handler.go ×4 · 14 introduced LOChandler.go ×4setup_task_tests.go ×3 · 9 introduced LOCsetup_task_tests.go ×3main.go ×1 · 4 introduced LOCmain.go ×1handler.go ×1 · 4 introduced LOChandler.go ×1handler.go ×2 · 15 introduced LOChandler.go ×2main.go ×1 · 2 introduced LOCmain.go ×1handler.go ×2 · 8 introduced LOChandler.go ×2handler.go ×4 · 170 introduced LOChandler.go ×4TestCreateKeyspaceError · introduced test · go.temporal.io/server/tools/cassandra/TestHandlerTestSuite/TestCreateKeyspaceErrorTestCreateKeyspaceErrorTestDropKeyspaceError · introduced test · go.temporal.io/server/tools/cassandra/TestHandlerTestSuite/TestDropKeyspaceErrorTestDropKeyspaceErrorTestCreateKeyspace · introduced test · go.temporal.io/server/tools/tests/TestSetupCQLSchemaTestSuite/TestCreateKeyspaceTestCreateKeyspaceTestSetupSchema · introduced test · go.temporal.io/server/tools/tests/TestSetupCQLSchemaTestSuite/TestSetupSchemaTestSetupSchemaTestDryrun · introduced test · go.temporal.io/server/tools/tests/TestUpdateCQLSchemaTestSuite/TestDryrunTestDryrunTestUpdateSchema · introduced test · go.temporal.io/server/tools/tests/TestUpdateCQLSchemaTestSuite/TestUpdateSchemaTestUpdateSchemaTestVerifyCompatibleVersion · introduced test · go.temporal.io/server/tools/tests/TestVersionTestSuite/TestVerifyCompatibleVersionTestVerifyCompatibleVers…Focused file · go.temporal.io/server/tools/cassandra/main.go · 273 LOCcassandra/main.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package cassandra
2
3 import (
4 "fmt"
5 "os"
6
7 "github.com/urfave/cli"
8 "go.temporal.io/server/common/headers"
9 "go.temporal.io/server/common/log"
10 dbschemas "go.temporal.io/server/schema"
11 "go.temporal.io/server/temporal/environment"
12 "go.temporal.io/server/tools/common/schema"
13 )
14
15 // RunTool runs the temporal-cassandra-tool command line tool
16 > func RunTool(args []string) error { main.go ×1
17 > app := buildCLIOptions()
18 > return app.Run(args)
19 > }
20
21 var osExit = os.Exit
22
23 // root handler for all cli commands
24 > func cliHandler(c *cli.Context, handler func(c *cli.Context, logger log.Logger) error, logger log.Logger) { handler.go ×4
25 > quiet := c.GlobalBool(schema.CLIOptQuiet)
26 > err := handler(c, logger)
27 > if err != nil && !quiet {
28 > osExit(1) main.go ×1
29 > }
30 }
31
32 > func buildCLIOptions() *cli.App { handler.go ×4
33 >
34 > app := cli.NewApp()
35 > app.Name = "temporal-cassandra-tool"
36 > app.Usage = "Command line tool for temporal cassandra operations"
37 > app.Version = headers.ServerVersion
38 > logger := log.NewCLILogger()
39 >
40 > app.Flags = []cli.Flag{
41 > cli.StringFlag{
42 > Name: schema.CLIFlagEndpoint,
43 > Value: environment.GetCassandraAddress(),
44 > Usage: "hostname or ip address of cassandra host to connect to",
45 > EnvVar: "CASSANDRA_HOST",
46 > },
47 > cli.IntFlag{
48 > Name: schema.CLIFlagPort,
49 > Value: environment.GetCassandraPort(),
50 > Usage: "Port of cassandra host to connect to",
51 > EnvVar: "CASSANDRA_PORT",
52 > },
53 > cli.StringFlag{
54 > Name: schema.CLIFlagUser,
55 > Value: "",
56 > Usage: "User name used for authentication for connecting to cassandra host",
57 > EnvVar: "CASSANDRA_USER",
58 > },
59 > cli.StringFlag{
60 > Name: schema.CLIFlagPassword,
61 > Value: "",
62 > Usage: "Password used for authentication for connecting to cassandra host",
63 > EnvVar: "CASSANDRA_PASSWORD",
64 > },
65 > cli.StringSliceFlag{
66 > Name: schema.CLIFlagAllowedAuthenticators,
67 > Value: nil,
68 > Usage: "List of authenticators allowed to be used by the gocql client while connecting to the server.",
69 > EnvVar: "CASSANDRA_ALLOWED_AUTHENTICATORS",
70 > },
71 > cli.IntFlag{
72 > Name: schema.CLIFlagTimeout,
73 > Value: defaultTimeout,
74 > Usage: "request Timeout in seconds used for cql client",
75 > EnvVar: "CASSANDRA_TIMEOUT",
76 > },
77 > cli.StringFlag{
78 > Name: schema.CLIFlagKeyspace,
79 > Value: "temporal",
80 > Usage: "name of the cassandra Keyspace",
81 > EnvVar: "CASSANDRA_KEYSPACE",
82 > },
83 > cli.StringFlag{
84 > Name: schema.CLIFlagDatacenter,
85 > Value: "",
86 > Usage: "enable NetworkTopologyStrategy by providing datacenter name",
87 > EnvVar: "CASSANDRA_DATACENTER",
88 > },
89 > cli.StringFlag{
90 > Name: schema.CLIOptAddressTranslator,
91 > Value: "",
92 > Usage: "name of address translator for cassandra hosts",
93 > EnvVar: "CASSANDRA_ADDRESS_TRANSLATOR",
94 > },
95 > cli.StringFlag{
96 > Name: schema.CLIOptAddressTranslatorOptions,
97 > Value: "",
98 > Usage: "colon-separated list of key=value pairs as options for address translator",
99 > EnvVar: "CASSANDRA_ADDRESS_TRANSLATOR_OPTIONS_CLI",
100 > },
101 > cli.BoolFlag{
102 > Name: schema.CLIFlagQuiet,
103 > Usage: "Don't set exit status to 1 on error",
104 > },
105 > cli.BoolFlag{
106 > Name: schema.CLIFlagDisableInitialHostLookup,
107 > Usage: "instructs gocql driver to only connect to the supplied hosts vs. attempting to lookup additional hosts via the system.peers table",
108 > EnvVar: "CASSANDRA_DISABLE_INITIAL_HOST_LOOKUP",
109 > },
110 > cli.BoolFlag{
111 > Name: schema.CLIFlagEnableTLS,
112 > Usage: "enable TLS",
113 > EnvVar: "CASSANDRA_ENABLE_TLS",
114 > },
115 > cli.StringFlag{
116 > Name: schema.CLIFlagTLSCertFile,
117 > Usage: "TLS cert file",
118 > EnvVar: "CASSANDRA_TLS_CERT",
119 > },
120 > cli.StringFlag{
121 > Name: schema.CLIFlagTLSKeyFile,
122 > Usage: "TLS key file",
123 > EnvVar: "CASSANDRA_TLS_KEY",
124 > },
125 > cli.StringFlag{
126 > Name: schema.CLIFlagTLSCaFile,
127 > Usage: "TLS CA file",
128 > EnvVar: "CASSANDRA_TLS_CA",
129 > },
130 > cli.StringFlag{
131 > Name: schema.CLIFlagTLSHostName,
132 > Value: "",
133 > Usage: "override for target server name",
134 > EnvVar: "CASSANDRA_TLS_SERVER_NAME",
135 > },
136 > cli.BoolFlag{
137 > Name: schema.CLIFlagTLSDisableHostVerification,
138 > Usage: "disable tls host name verification (tls must be enabled)",
139 > EnvVar: "CASSANDRA_TLS_DISABLE_HOST_VERIFICATION",
140 > },
141 > }
142 >
143 > app.Commands = []cli.Command{
144 > {
145 > Name: "setup-schema",
146 > Aliases: []string{"setup"},
147 > Usage: "setup initial version of cassandra schema",
148 > Flags: []cli.Flag{
149 > cli.StringFlag{
150 > Name: schema.CLIFlagVersion,
151 > Usage: "initial version of the schema, cannot be used with disable-versioning",
152 > },
153 > cli.StringFlag{
154 > Name: schema.CLIFlagSchemaFile,
155 > Usage: "path to the .cql schema file; if un-specified, will just setup versioning tables",
156 > },
157 > cli.StringFlag{
158 > Name: schema.CLIFlagSchemaName,
159 > Usage: fmt.Sprintf("name of embedded schema directory with .cql file, one of: %v",
160 > dbschemas.PathsByDB("cassandra")),
161 > },
162 > cli.BoolFlag{
163 > Name: schema.CLIFlagDisableVersioning,
164 > Usage: "disable setup of schema versioning",
165 > },
166 > cli.BoolFlag{
167 > Name: schema.CLIFlagOverwrite,
168 > Usage: "drop all existing tables before setting up new schema",
169 > },
170 > },
171 > Action: func(c *cli.Context) {
172 > cliHandler(c, setupSchema, logger) handler.go ×4
173 > },
174 },
175 {
176 Name: "update-schema",
177 Aliases: []string{"update"},
178 Usage: "update cassandra schema to a specific version",
179 Flags: []cli.Flag{
180 cli.StringFlag{
181 Name: schema.CLIFlagTargetVersion,
182 Usage: "target version for the schema update, defaults to latest",
183 },
184 cli.StringFlag{
185 Name: schema.CLIFlagSchemaDir,
186 Usage: "path to directory containing versioned schema",
187 },
188 cli.StringFlag{
189 Name: schema.CLIFlagSchemaName,
190 Usage: fmt.Sprintf("name of embedded versioned schema, one of: %v",
191 dbschemas.PathsByDB("cassandra")),
192 },
193 },
194 > Action: func(c *cli.Context) { handler.go ×4
195 > cliHandler(c, updateSchema, logger)
196 > },
197 },
198 {
199 Name: "create-keyspace",
200 Aliases: []string{"create", "create-Keyspace"},
201 Usage: "creates a keyspace with simple strategy or network topology if datacenter name is provided",
202 Flags: []cli.Flag{
203 cli.StringFlag{
204 Name: schema.CLIFlagKeyspace,
205 Usage: "name of the keyspace",
206 },
207 cli.IntFlag{
208 Name: schema.CLIFlagReplicationFactor,
209 Value: 1,
210 Usage: "replication factor for the keyspace",
211 },
212 cli.StringFlag{
213 Name: schema.CLIFlagDatacenter,
214 Value: "",
215 Usage: "enable NetworkTopologyStrategy by providing datacenter name",
216 },
217 },
218 > Action: func(c *cli.Context) { handler.go ×2
219 > cliHandler(c, createKeyspace, logger)
220 > },
221 },
222 {
223 Name: "drop-keyspace",
224 Aliases: []string{"drop"},
225 Usage: "drops a keyspace with simple strategy or network topology if datacenter name is provided",
226 Flags: []cli.Flag{
227 cli.StringFlag{
228 Name: schema.CLIFlagKeyspace,
229 Usage: "name of the keyspace",
230 },
231 cli.IntFlag{
232 Name: schema.CLIFlagReplicationFactor,
233 Value: 1,
234 Usage: "replication factor for the keyspace",
235 },
236 cli.StringFlag{
237 Name: schema.CLIFlagDatacenter,
238 Value: "",
239 Usage: "enable NetworkTopologyStrategy by providing datacenter name",
240 },
241 cli.BoolFlag{
242 Name: schema.CLIFlagForce,
243 Usage: "don't prompt for confirmation",
244 },
245 },
246 > Action: func(c *cli.Context) { handler.go ×2
247 > drop := c.Bool(schema.CLIOptForce)
248 > if !drop {
249 keyspace := c.String(schema.CLIOptKeyspace)
250 fmt.Printf("Are you sure you want to drop keyspace %q (y/N)? ", keyspace)
251 y := ""
252 _, _ = fmt.Scanln(&y)
253 if y == "y" || y == "Y" {
254 drop = true
255 }
256 }
257 > if drop { handler.go ×2
258 > cliHandler(c, dropKeyspace, logger)
259 > }
260 },
261 },
262 {
263 Name: "validate-health",
264 Aliases: []string{"vh"},
265 Usage: "validates health of cassandra by attempting to establish CQL session to system keyspace",
266 Action: func(c *cli.Context) {
267 cliHandler(c, validateHealth, logger)
268 },
269 },
270 }
271
272 > return app handler.go ×4
273 }