Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add script to debug gRPC endpoints #114

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions script/grpc-probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

akash_api=$(realpath "$SCRIPT_DIR/../")

if [ ! -d "${akash_api}/vendor" ]; then
echo "for script to work run \"make modvendor\""
exit 1
fi

short_opts=h
long_opts=help/host:/mode: # those who take an arg END with :

host=localhost:8081
mode=

while getopts ":$short_opts-:" o; do
case $o in
:)
echo >&2 "option -$OPTARG needs an argument"
continue
;;
'?')
echo >&2 "bad option -$OPTARG"
continue
;;
-)
o=${OPTARG%%=*}
OPTARG=${OPTARG#"$o"}
lo=/$long_opts/
case $lo in
*"/$o"[!/:]*"/$o"[!/:]*)
echo >&2 "ambiguous option --$o"
continue
;;
*"/$o"[:/]*)
;;
*)
o=$o${lo#*"/$o"};
o=${o%%[/:]*}
;;
esac

case $lo in
*"/$o/"*)
OPTARG=
;;
*"/$o:/"*)
case $OPTARG in
'='*)
OPTARG=${OPTARG#=}
;;
*)
eval "OPTARG=\$$OPTIND"
if [ "$OPTIND" -le "$#" ] && [ "$OPTARG" != -- ]; then
OPTIND=$((OPTIND + 1))
else
echo >&2 "option --$o needs an argument"
continue
fi
;;
esac
;;
*) echo >&2 "unknown option --$o"; continue;;
esac
esac
case "$o" in
host)
host=$OPTARG
;;
mode)
case "$OPTARG" in
plaintext|insecure)
;;
*)
echo >&2 "option --$o can be plaintext|insecure"
;;
esac

mode=-$OPTARG
;;
esac
done
shift "$((OPTIND - 1))"

grpcurl \
"$mode" \
-use-reflection \
-proto="${akash_api}/proto/provider/akash/inventory/v1/service.proto" \
-proto="${akash_api}/proto/provider/akash/provider/v1/service.proto" \
-import-path="${akash_api}/proto/provider" \
-import-path="${akash_api}/proto/node" \
-import-path="${akash_api}/vendor/github.com/cosmos/cosmos-sdk/third_party/proto" \
-import-path="${akash_api}/vendor" \
"$host" \
"$@"
Loading