Browse code

Add stats calls

Jaidyn Levesque authored on 2019-06-19 16:40:47
Showing 2 changed files
... ...
@@ -986,6 +986,71 @@
986 986
 
987 987
 
988 988
 
989
+;; —————————————————————————————————————
990
+;; REPO CALLS
991
+
992
+;; NIL → STRING || (NIL STRING)
993
+(defun repo-fsck ()
994
+  "Remove repo lock-files.
995
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-fsck"
996
+  (bind-api-result (ipfs-call "repo/fsck" '()) (gethash "Message" result)))
997
+
998
+;; NIL → ALIST || (NIL STRING)
999
+(defun repo-gc ()
1000
+  "Perform garbage collection on the repo.
1001
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-gc"
1002
+  (bind-api-alist (ipfs-call "repo/gc" '())))
1003
+
1004
+;; NIL → ALIST || (NIL STRING)
1005
+(defun repo-stat ()
1006
+  "Get stats for the current repo.
1007
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-stat"
1008
+  (bind-api-alist (ipfs-call "repo/stat" '())))
1009
+
1010
+;; NIL → ALIST || (NIL STRING)
1011
+(defun repo-verify ()
1012
+  "Verify that all repo blocks aren't corrupted.
1013
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-verify"
1014
+  (bind-api-alist (ipfs-call "repo/verify" '())))
1015
+
1016
+;; NIL → NUMBER || (NIL STRING)
1017
+(defun repo-version ()
1018
+  "Show the repo version.
1019
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-version"
1020
+  (bind-api-result (ipfs-call "repo/version" '())
1021
+		   (read-from-string (gethash "Version" result))))
1022
+
1023
+
1024
+
1025
+
1026
+;; —————————————————————————————————————
1027
+;; STATS CALLS
1028
+
1029
+;; NIL → ALIST || (NIL STRING)
1030
+(defun stats-bitswap ()
1031
+  "Show diagnostics on bitswap.
1032
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-bitswap"
1033
+  (bind-api-alist (ipfs-call "stats/bitswap" '())))
1034
+
1035
+;; [:STRING :STRING :STRING] → ALIST || (NIL STRING)
1036
+(defun stats-bw (&key (peer nil) (proto nil) (interval nil))
1037
+  "Return bandwidth information.
1038
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-bw"
1039
+  (bind-api-alist
1040
+    (ipfs-call "stats/bitswap"
1041
+	       `(,(when peer `("peer" ,peer)) ,(when proto `("proto" ,proto))
1042
+                 ,(when interval `("interval" ,interval))
1043
+		 ,(when interval `("poll" 'T))))))
1044
+
1045
+;; NIL → ALIST || (NIL STRING)
1046
+(defun stats-repo ()
1047
+  "Show diagnostics on current repo.
1048
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-repo"
1049
+  (bind-api-alist (ipfs-call "stats/repo" '())))
1050
+
1051
+
1052
+
1053
+
989 1054
 ;; —————————————————————————————————————
990 1055
 ;; VERSION CALLS
991 1056
 
... ...
@@ -140,6 +140,18 @@
140 140
     :refs
141 141
     :refs-local
142 142
 
143
+    ;; repo calls
144
+    :repo-fsck
145
+    :repo-gc
146
+    :repo-stat
147
+    :repo-verify
148
+    :repo-version
149
+
150
+    ;; stats calls
151
+    :stats-bitswap
152
+    :stats-bw
153
+    :stats-repo
154
+
143 155
     ;; version calls
144 156
     :version
145 157
     :version-deps))