From 67e9ec5eaadabd654a0736095bdbe44a67ff8ff9 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Tue, 3 Sep 2024 11:49:20 +0200 Subject: [PATCH] Add dev scripts for inspecting redis streams --- nix/dev-scripts.nix | 10 ++++++++++ nix/scripts/redis-list-streams | 20 ++++++++++++++++++++ nix/scripts/redis-stream-info | 13 +++++++++++++ 3 files changed, 43 insertions(+) create mode 100755 nix/scripts/redis-list-streams create mode 100755 nix/scripts/redis-stream-info diff --git a/nix/dev-scripts.nix b/nix/dev-scripts.nix index 7d6f65c7..c5758b51 100644 --- a/nix/dev-scripts.nix +++ b/nix/dev-scripts.nix @@ -8,6 +8,16 @@ inherit system; }; + redis-list-streams = devshell-tools.lib.installScript { + script = ./scripts/redis-list-streams; + inherit system; + }; + + redis-stream-info = devshell-tools.lib.installScript { + script = ./scripts/redis-stream-info; + inherit system; + }; + k8s-reprovision = devshell-tools.lib.installScript { script = ./scripts/k8s-reprovision; inherit system; diff --git a/nix/scripts/redis-list-streams b/nix/scripts/redis-list-streams new file mode 100755 index 00000000..d8bcff2e --- /dev/null +++ b/nix/scripts/redis-list-streams @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +host="${RS_REDIS_HOST:-localhost}" +if [ -n "$1" ]; then + host="$1" +fi +port="${RS_REDIS_PORT:-6379}" +if [ -n "$2" ]; then + port="$2" +fi +db_opt="" +if [ -n "$RS_REDIS_DB" ]; then + db_opt="-n $RS_REDIS_DB" +fi +db_pass="" +if [ -n "$RS_REDIS_PASSWORD" ]; then + db_pass="-a $RS_REDIS_PASSWORD" +fi + +redis-cli -e --json -h "$host" -p "$port" $db_opt $db_pass scan 0 type stream | jq -r '.[1][]' diff --git a/nix/scripts/redis-stream-info b/nix/scripts/redis-stream-info new file mode 100755 index 00000000..c898cc85 --- /dev/null +++ b/nix/scripts/redis-stream-info @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +host="${RS_REDIS_HOST:-localhost}" +port="${RS_REDIS_PORT:-6379}" +db_opt="" +if [ -n "$RS_REDIS_DB" ]; then + db_opt="-n $RS_REDIS_DB" +fi +db_pass="" +if [ -n "$RS_REDIS_PASSWORD" ]; then + db_pass="-a $RS_REDIS_PASSWORD" +fi +redis-cli -e --json -h "$host" -p "$port" $db_opt $db_pass XINFO STREAM "$1"