stargate / stargate-grpc-go-client

A golang gRPC client for https://stargate.io
Apache License 2.0
18 stars 7 forks source link

Feature request: default keyspace option #28

Open SpencerC opened 2 years ago

SpencerC commented 2 years ago

Current design

Callers must chose between including the keyspace in each query:

_, err = stargateClient.ExecuteQuery(&sgpb.Query{
    Cql:        "INSERT INTO main_keyspace.some_table (id) VALUES ('abcd')",
})

or adding a crazy complicated parameter to every query

_, err = stargateClient.ExecuteQuery(&sgpb.Query{
    Cql:        "INSERT INTO some_table (id) VALUES ('abcd')",
    Parameters: &sgpb.QueryParameters{Keyspace: &wrapperspb.StringValue{Value: "main_keyspace"}},
})

Proposed design

sc, err := client.NewStargateClientWithConn(conn, cilent.WithDefaultKeyspace("main_keyspace"))

_, err = stargateClient.ExecuteQuery(&sgpb.Query{
    Cql:        "INSERT INTO some_table (id) VALUES ('abcd')",
    // implicitly uses "main_keyspace"
})

_, err = stargateClient.ExecuteQuery(&sgpb.Query{
    Cql:        "INSERT INTO some_table (id) VALUES ('abcd')",
    Parameters: &sgpb.QueryParameters{Keyspace: &wrapperspb.StringValue{Value: "overriding_keyspace"}},
})