Skip to content

Commit

Permalink
feat: added connect-go for engine (#879)
Browse files Browse the repository at this point in the history
This PR will include the connect-go updates only related to engine; I am
relying on the CI pipeline tests to verify it's correctness - which atm
looks good. This PR will also include frontend changes that will allow
me to connect to engine.

Co-authored-by: Anders Schwartz <anders.schwartz@kurtosistech.com>
  • Loading branch information
Peeeekay and adschwartz committed Aug 18, 2023
1 parent c26d7c4 commit 8c0121c
Show file tree
Hide file tree
Showing 108 changed files with 8,170 additions and 1,858 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions api/scripts/protobuf-bindings-generator.sh
Expand Up @@ -4,10 +4,8 @@
# It requires the Golang Protobuf extension to the 'protoc' compiler, as well as the Golang gRPC extension

set -euo pipefail
# script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"



script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"
api_dir_path="$(dirname "${script_dir_path}")"
# ==================================================================================================
# Constants
# ==================================================================================================
Expand Down Expand Up @@ -156,7 +154,7 @@ generate_golang_bindings() {

go_out_flag="--go_out=${output_abs_dirpath}"
go_grpc_out_flag="--go-grpc_out=${output_abs_dirpath}"

connect_go_grpc_flag="--connect-go_out=${output_abs_dirpath}"
fully_qualified_go_pkg="${go_module}/${output_rel_dirpath}"
fully_qualified_go_pkg="${fully_qualified_go_pkg%%/}"
for input_filepath in $(find "${input_abs_dirpath}" -type f -name "*${PROTOBUF_FILE_EXT}"); do
Expand All @@ -165,7 +163,7 @@ generate_golang_bindings() {
# See also: https://github.com/golang/protobuf/issues/1272
go_module_flag="--go_opt=module=${fully_qualified_go_pkg}"
go_grpc_module_flag="--go-grpc_opt=module=${fully_qualified_go_pkg}"

connect_go_module_flag="--connect-go_opt=module=${fully_qualified_go_pkg}"
# Way back in the day, GRPC's Go binding generation used to create an interface for servers to implement
# When you added a new method in the .proto file, the interface would get a new method, your implementation of the
# interface wouldn't have that method, and you'd get a compile error
Expand All @@ -185,6 +183,8 @@ generate_golang_bindings() {
"${go_grpc_out_flag}" \
"${go_grpc_module_flag}" \
"${go_grpc_unimplemented_servers_flag}" \
"${connect_go_grpc_flag}" \
"${connect_go_module_flag}" \
"${input_filepath}"; then
echo "Error: An error occurred generating Golang bindings for file '${input_filepath}'" >&2
return 1
Expand Down Expand Up @@ -246,6 +246,19 @@ generate_typescript_bindings() {
echo "Error: An error occurred generating TypeScript Web bindings for file '${input_filepath}'" >&2
return 1
fi

if ! "${node_protoc_bin_filepath}" \
-I="${input_abs_dirpath}" \
"--plugin=protoc-gen-es=${api_dir_path}/typescript/node_modules/.bin/protoc-gen-es" \
"--es_out=${output_abs_dirpath}/connect" \
"--es_opt=target=js+dts" \
"--plugin=protoc-gen-connect-es=${api_dir_path}/typescript/node_modules/.bin/protoc-gen-connect-es" \
"--connect-es_out=${output_abs_dirpath}/connect" \
"--connect-es_opt=target=js+dts" \
"${input_filepath}"; then
echo "Error: An error occurred generating TypeScript Node bindings for file '${input_filepath}'" >&2
return 1
fi
done
}

Expand Down Expand Up @@ -273,4 +286,4 @@ generator_func="${generators["${lang}"]}"
# 3) Tying the protoc inside the Dockerfile and the protoc on the user's machine together using a protoc version check
# 4) Adding the locally-generated Go output files to .gitignore
# 5) Adding the locally-generated Go output files to .dockerignore (since they'll get generated inside Docker)
"${generator_func}" "${input_abs_dirpath}" "${output_abs_dirpath}"
"${generator_func}" "${input_abs_dirpath}" "${output_abs_dirpath}"

0 comments on commit 8c0121c

Please sign in to comment.