Skip to content

Commit

Permalink
feat: add script to debug gRPC endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jan 27, 2024
1 parent 361c75d commit c452be7
Showing 1 changed file with 97 additions and 0 deletions.
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" \
"$@"

0 comments on commit c452be7

Please sign in to comment.