summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaidyn Levesque <jadedctrl@teknik.io>2019-06-19 16:40:47 +0000
committerJaidyn Levesque <jadedctrl@teknik.io>2019-06-19 16:40:47 +0000
commitc2b24232a220dae64feb64220fbe6ad570e3d7bb (patch)
tree6d65c44a59b99a833232119a7e7ab45113973fe8
parentf572f0c0e8fb71563d58157129c849f37a4bfb31 (diff)
downloadcl-ipfs-api2-c2b24232a220dae64feb64220fbe6ad570e3d7bb.tar.bz2
cl-ipfs-api2-c2b24232a220dae64feb64220fbe6ad570e3d7bb.zip
Add stats calls
-rw-r--r--main.lisp65
-rw-r--r--package.lisp12
2 files changed, 77 insertions, 0 deletions
diff --git a/main.lisp b/main.lisp
index 9e67657..4204237 100644
--- a/main.lisp
+++ b/main.lisp
@@ -987,6 +987,71 @@
;; —————————————————————————————————————
+;; REPO CALLS
+
+;; NIL → STRING || (NIL STRING)
+(defun repo-fsck ()
+ "Remove repo lock-files.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-fsck"
+ (bind-api-result (ipfs-call "repo/fsck" '()) (gethash "Message" result)))
+
+;; NIL → ALIST || (NIL STRING)
+(defun repo-gc ()
+ "Perform garbage collection on the repo.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-gc"
+ (bind-api-alist (ipfs-call "repo/gc" '())))
+
+;; NIL → ALIST || (NIL STRING)
+(defun repo-stat ()
+ "Get stats for the current repo.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-stat"
+ (bind-api-alist (ipfs-call "repo/stat" '())))
+
+;; NIL → ALIST || (NIL STRING)
+(defun repo-verify ()
+ "Verify that all repo blocks aren't corrupted.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-verify"
+ (bind-api-alist (ipfs-call "repo/verify" '())))
+
+;; NIL → NUMBER || (NIL STRING)
+(defun repo-version ()
+ "Show the repo version.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-repo-version"
+ (bind-api-result (ipfs-call "repo/version" '())
+ (read-from-string (gethash "Version" result))))
+
+
+
+
+;; —————————————————————————————————————
+;; STATS CALLS
+
+;; NIL → ALIST || (NIL STRING)
+(defun stats-bitswap ()
+ "Show diagnostics on bitswap.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-bitswap"
+ (bind-api-alist (ipfs-call "stats/bitswap" '())))
+
+;; [:STRING :STRING :STRING] → ALIST || (NIL STRING)
+(defun stats-bw (&key (peer nil) (proto nil) (interval nil))
+ "Return bandwidth information.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-bw"
+ (bind-api-alist
+ (ipfs-call "stats/bitswap"
+ `(,(when peer `("peer" ,peer)) ,(when proto `("proto" ,proto))
+ ,(when interval `("interval" ,interval))
+ ,(when interval `("poll" 'T))))))
+
+;; NIL → ALIST || (NIL STRING)
+(defun stats-repo ()
+ "Show diagnostics on current repo.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-stats-repo"
+ (bind-api-alist (ipfs-call "stats/repo" '())))
+
+
+
+
+;; —————————————————————————————————————
;; VERSION CALLS
;; NIL → STRING
diff --git a/package.lisp b/package.lisp
index e305d87..c1de9f9 100644
--- a/package.lisp
+++ b/package.lisp
@@ -140,6 +140,18 @@
:refs
:refs-local
+ ;; repo calls
+ :repo-fsck
+ :repo-gc
+ :repo-stat
+ :repo-verify
+ :repo-version
+
+ ;; stats calls
+ :stats-bitswap
+ :stats-bw
+ :stats-repo
+
;; version calls
:version
:version-deps))