Skip to content
This repository was archived by the owner on Oct 26, 2023. It is now read-only.

Commit a668f9f

Browse files
authored
feat: schema metadata API support (#37)
* feat: support for schema API code generation Modifies the gRPC / proto code generation helper script to generate both the existing ingester service code, and the schema service code. * test: composable test client + write helpers Refactors the test helper code into two distinct responsibilities that can be composed together to build up more complex test cases: * openNewDatabase: initialise an IOx client with a random database * writeDataset: perform a write to a specified db/table Previously initialising a client also returned the write destination, which restricted tests to writing to a single (pre-determined) table / db. * feat(metadata): schema API client Implements a GetSchema() metadata call that returns the set of columns and their data types for a specific table within a namespace. Redefines the column data types defined in the proto spec, decoupling callers from the generated wire format (internal) representation. Currently fetches all tables for a given namespace and filters the results for the desired table in the client - this should be replaced with a more efficient table-orientated schema lookup API once it is available in IOx: https://github.com/influxdata/influxdb_iox/issues/4997
1 parent da02174 commit a668f9f

7 files changed

+935
-35
lines changed

generate_influxdb_iox_protobuf.sh

+24-10
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,29 @@ git clone \
2929
https://github.com/influxdata/influxdb_iox \
3030
gen
3131

32-
filenames=$(find gen/generated_types/protos/influxdata/iox/ingester -name '*.proto')
33-
protoc \
34-
--proto_path=gen/generated_types/protos/ \
35-
--plugin protoc-gen-go="$(which protoc-gen-go)" \
36-
--plugin protoc-gen-go-grpc="$(which protoc-gen-go-grpc)" \
37-
--go_out gen \
38-
--go-grpc_out gen \
39-
${filenames}
40-
41-
mv gen/github.com/influxdata/iox/ingester/v1/*.go internal/ingester/
32+
# Generate Go files for the specified IOx service.
33+
#
34+
# $1: the IOx proto directory name to generate code for
35+
#
36+
# Generates directories by name from
37+
# https://github.com/influxdata/influxdb_iox/tree/main/generated_types/protos/influxdata/iox
38+
function generate_service {
39+
filenames=$(find "gen/generated_types/protos/influxdata/iox/${1}" -name '*.proto')
40+
protoc \
41+
--proto_path=gen/generated_types/protos/ \
42+
--plugin protoc-gen-go="$(which protoc-gen-go)" \
43+
--plugin protoc-gen-go-grpc="$(which protoc-gen-go-grpc)" \
44+
--go_out gen \
45+
--go-grpc_out gen \
46+
${filenames}
47+
48+
mkdir "internal/${1}" 2>/dev/null || true
49+
mv gen/github.com/influxdata/iox/"${1}"/v1/*.go "internal/${1}/"
50+
51+
echo "generated ${1}"
52+
}
53+
54+
generate_service "ingester"
55+
generate_service "schema"
4256

4357
rm -rf gen

0 commit comments

Comments
 (0)