Add stats calls

This commit is contained in:
Jaidyn Levesque 2019-06-19 11:40:47 -05:00
parent f572f0c0e8
commit c2b24232a2
2 changed files with 77 additions and 0 deletions

View File

@ -986,6 +986,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 ;; VERSION CALLS

View File

@ -140,6 +140,18 @@
:refs :refs
:refs-local :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 calls
:version :version
:version-deps)) :version-deps))