Skip to content

Commit a855b12

Browse files
committed
feat(informative): run.sh for local development
1 parent 0eff5c9 commit a855b12

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ __pycache__
5555

5656
venv
5757
*.bin
58-
.env*
58+
.env

informative-indexer/.env.example

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# For local development only
2+
3+
## Kafka credentials
4+
export KAFKA_API_KEY=""
5+
export KAFKA_API_SECRET=""
6+
export KAFKA_BOOTSTRAP_SERVER=""
7+
8+
## RPC for sweeper
9+
export RPC_ENDPOINTS=""
10+
export RPC_TIMEOUT_IN_SECONDS=""
11+
export REBALANCE_INTERVAL=""
12+
13+
## Database connection
14+
export DB_CONNECTION_STRING=""

informative-indexer/run.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SCRIPT_DIR=$(cd $(dirname $0) ; pwd -P)
6+
7+
TASK=$1
8+
ARGS=${@:2}
9+
10+
help__sweep="sweep <..args> : run sweep"
11+
task__sweep() {
12+
local chain=$1
13+
14+
if [ -z "$chain" ]; then
15+
echo "usage: $0 sweep <chain>"
16+
exit
17+
fi
18+
19+
go build -o informative-indexer.bin .
20+
21+
source .env
22+
23+
./informative-indexer.bin sweep --bootstrap-server $KAFKA_BOOTSTRAP_SERVER \
24+
--block-results-topic ${chain}-local-informative-indexer-block-results-messages \
25+
--kafka-api-key $KAFKA_API_KEY \
26+
--kafka-api-secret $KAFKA_API_SECRET \
27+
--claim-check-bucket ${chain}-local-informative-indexer-large-block-results \
28+
--claim-check-threshold-mb 1 \
29+
--db $DB_CONNECTION_STRING \
30+
--chain $chain \
31+
--rebalance-interval $REBALANCE_INTERVAL \
32+
--workers 4
33+
}
34+
35+
help__flush="flush <..args> : run flush"
36+
task__flush() {
37+
local chain=$1
38+
39+
if [ -z "$chain" ]; then
40+
echo "usage: $0 flush <chain> <id>"
41+
exit
42+
fi
43+
44+
go build -o informative-indexer.bin .
45+
46+
source .env
47+
48+
./informative-indexer.bin flush --bootstrap-server $KAFKA_BOOTSTRAP_SERVER \
49+
--block-results-topic ${chain}-local-informative-indexer-block-results-messages \
50+
--kafka-api-key $KAFKA_API_KEY \
51+
--kafka-api-secret $KAFKA_API_SECRET \
52+
--block-results-consumer-group ${chain}-local-generic-indexer-flusher \
53+
--block-results-claim-check-bucket ${chain}-local-informative-indexer-large-block-results \
54+
--claim-check-threshold-mb 1 \
55+
--db $DB_CONNECTION_STRING \
56+
--chain $chain \
57+
--environment local \
58+
--id 1
59+
}
60+
61+
list_all_helps() {
62+
compgen -v | egrep "^help__.*"
63+
}
64+
65+
NEW_LINE=$'\n'
66+
if type -t "task__$TASK" &>/dev/null; then
67+
task__$TASK $ARGS
68+
else
69+
echo "usage: $0 <task> [<..args>]"
70+
echo "task:"
71+
72+
HELPS=""
73+
for help in $(list_all_helps)
74+
do
75+
76+
HELPS="$HELPS ${help/help__/} |-- ${!help}$NEW_LINE"
77+
done
78+
79+
echo "$HELPS" | column -t -s "|"
80+
exit
81+
fi

0 commit comments

Comments
 (0)