|
| 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