Skip to content

Instantly share code, notes, and snippets.

@mattlord
Last active May 2, 2024 12:12
Show Gist options
  • Save mattlord/ca11dbb8cb33d0d65956a29a7844a910 to your computer and use it in GitHub Desktop.
Save mattlord/ca11dbb8cb33d0d65956a29a7844a910 to your computer and use it in GitHub Desktop.
grpcurl examples with Vitess
❯ grpcurl -plaintext -format json -import-path ${VTROOT}/proto -proto vtgateservice.proto \
  -H 'username: guser1'  -H 'password: gpass1' \
  -d '{"tablet_type":"RDONLY", "vgtid":{ "shard_gtids": [{"keyspace":"", "shard":"", "gtid":"current"}]} }' \
  localhost:15306 vtgateservice.Vitess/VStream
❯ grpcurl -plaintext -format json -import-path ${VTROOT}/proto -proto ${VTROOT}/proto/vtctlservice.proto \
  -d '{"keyspace":"commerce", "sql":"create table t1 (id int)", "ddl_strategy":"direct"}' \
  localhost:15999 vtctlservice.Vtctld/ApplySchema
{
  "rowsAffectedByShard": {
    "0": "0"
  }
}
❯ grpcurl -plaintext -format json -import-path ${VTROOT}/proto -proto vtctlservice.proto \
  -d '{"keyspace":"commerce", "shard":"0", "tablet_type":"PRIMARY"}' \
  localhost:15999 vtctlservice.Vtctld/GetTablets
{
  "tablets": [
    {
      "alias": {
        "cell": "zone1",
        "uid": 100
      },
      "hostname": "localhost",
      "portMap": {
        "grpc": 16100,
        "vt": 15100
      },
      "keyspace": "commerce",
      "shard": "0",
      "type": "PRIMARY",
      "mysqlHostname": "localhost",
      "mysqlPort": 17100,
      "primaryTermStartTime": {
        "seconds": "1714650530",
        "nanoseconds": 641981000
      },
      "defaultConnCollation": 255
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment