[vtadmin-api] Add /api/schemas endpoint to vtadmin-api#7432
Merged
rohit-nayak-ps merged 3 commits intovitessio:masterfrom Feb 4, 2021
Merged
[vtadmin-api] Add /api/schemas endpoint to vtadmin-api#7432rohit-nayak-ps merged 3 commits intovitessio:masterfrom
rohit-nayak-ps merged 3 commits intovitessio:masterfrom
Conversation
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
aea8170 to
8bf8622
Compare
ajm188
approved these changes
Feb 3, 2021
| } | ||
|
|
||
| // getSchemas returns all of the schemas across all keyspaces in the given cluster. | ||
| func (api *API) getSchemas(ctx context.Context, c *cluster.Cluster, tablets []*vtadminpb.Tablet) ([]*vtadminpb.Schema, error) { |
Contributor
There was a problem hiding this comment.
TIOLI: I know we talked a bit about this file potentially growing very large as the API surface area grows, and these methods don't actually depend on api for anything, so if you wanted to you could make these top-level private functions in another file, but also this is fine as-is.
Contributor
Author
There was a problem hiding this comment.
I'll leave it for now. I agree with you on one file offering better readability. Even though these methods don't use api directly, the colocation seems good. One day I'll get used to the verbosity.
| tabletSchemas map[string]*tabletmanagerdata.SchemaDefinition | ||
| req *vtadminpb.GetSchemasRequest | ||
| expected *vtadminpb.GetSchemasResponse | ||
| }{ |
Contributor
There was a problem hiding this comment.
Ugh, I am sorry lol. These are great tests though!
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
ajm188
approved these changes
Feb 3, 2021
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Sara Bee 855595+doeg@users.noreply.github.com
Description
A simplified version of our Slack-internal /api/schemas endpoint. Notably:
"Don't forget" to expand the
api_test.godiff 😭@ajm188 thanks as always for weathering my
incessant whiningquestions!Queries against local Vitess
curl "http://localhost:14200/api/schemas" | jq .{ "result": { "schemas": [ { "cluster": { "id": "id1", "name": "cluster1" }, "keyspace": "commerce", "table_definitions": [ { "name": "customer_seq", "schema": "CREATE TABLE `customer_seq` (\n `id` int(11) NOT NULL,\n `next_id` bigint(20) DEFAULT NULL,\n `cache` bigint(20) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='vitess_sequence'", "columns": [ "id", "next_id", "cache" ], "primary_key_columns": [ "id" ], "type": "BASE TABLE", "data_length": 16384, "row_count": 1, "fields": [ { "name": "id", "type": 263, "table": "customer_seq", "org_table": "customer_seq", "database": "vt_commerce", "org_name": "id", "column_length": 11, "charset": 63, "flags": 53251 }, { "name": "next_id", "type": 265, "table": "customer_seq", "org_table": "customer_seq", "database": "vt_commerce", "org_name": "next_id", "column_length": 20, "charset": 63, "flags": 32768 }, { "name": "cache", "type": 265, "table": "customer_seq", "org_table": "customer_seq", "database": "vt_commerce", "org_name": "cache", "column_length": 20, "charset": 63, "flags": 32768 } ] }, { "name": "order_seq", "schema": "CREATE TABLE `order_seq` (\n `id` int(11) NOT NULL,\n `next_id` bigint(20) DEFAULT NULL,\n `cache` bigint(20) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='vitess_sequence'", "columns": [ "id", "next_id", "cache" ], "primary_key_columns": [ "id" ], "type": "BASE TABLE", "data_length": 16384, "row_count": 1, "fields": [ { "name": "id", "type": 263, "table": "order_seq", "org_table": "order_seq", "database": "vt_commerce", "org_name": "id", "column_length": 11, "charset": 63, "flags": 53251 }, { "name": "next_id", "type": 265, "table": "order_seq", "org_table": "order_seq", "database": "vt_commerce", "org_name": "next_id", "column_length": 20, "charset": 63, "flags": 32768 }, { "name": "cache", "type": 265, "table": "order_seq", "org_table": "order_seq", "database": "vt_commerce", "org_name": "cache", "column_length": 20, "charset": 63, "flags": 32768 } ] }, { "name": "product", "schema": "CREATE TABLE `product` (\n `sku` varbinary(128) NOT NULL,\n `description` varbinary(128) DEFAULT NULL,\n `price` bigint(20) DEFAULT NULL,\n PRIMARY KEY (`sku`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8", "columns": [ "sku", "description", "price" ], "primary_key_columns": [ "sku" ], "type": "BASE TABLE", "data_length": 16384, "fields": [ { "name": "sku", "type": 10262, "table": "product", "org_table": "product", "database": "vt_commerce", "org_name": "sku", "column_length": 128, "charset": 63, "flags": 20611 }, { "name": "description", "type": 10262, "table": "product", "org_table": "product", "database": "vt_commerce", "org_name": "description", "column_length": 128, "charset": 63, "flags": 128 }, { "name": "price", "type": 265, "table": "product", "org_table": "product", "database": "vt_commerce", "org_name": "price", "column_length": 20, "charset": 63, "flags": 32768 } ] } ] } ] }, "ok": true }curl "http://localhost:14200/api/schemas?cluster=nope" | jq .{ "result": {}, "ok": true }Related Issue(s)
Checklist
Deployment Notes
N/A
Impacted Areas in Vitess
Components that this PR will affect: