git ssb

4+

Dominic / scuttlebot



Commit 484aa4e616c9dcc5dc7d8e706228aaa005a374dd

implement a status() method

Dominic Tarr committed on 6/22/2017, 6:59:28 AM
Parent: fd6d70a30dab618ef7610aa8d4df18b38eed8c25

Files changed

api.mdchanged
index.jschanged
plugins/gossip/index.jschanged
plugins/replicate/legacy.jschanged
api.mdView
@@ -359,5 +359,11 @@
359359 to represent progress. Currently implemented are `migration` (legacy->flume)
360360 migration progress and `indexes` (index regeneration).
361361
362362
363 +## status: sync
364 +
365 +returns an object reflecting the status of various ssb operations,
366 +such as db read activity, connection statuses, etc, etc. The purpose is to provide
367 +an overview of how ssb is working.
368 +
363369 ## getVectorClock: async
index.jsView
@@ -91,8 +91,12 @@
9191 progress : function () {
9292 return ssb.progress
9393 },
9494
95 + status : function () {
96 + return {db: ssb.status, sync: since() }
97 + },
98 +
9599 //temporary!
96100 _flumeUse :
97101 function (name, flumeview) {
98102 ssb.use(name, flumeview)
plugins/gossip/index.jsView
@@ -48,8 +48,10 @@
4848 var home = ref.parseAddress(server.getAddress())
4949
5050 var stateFile = AtomicFile(path.join(config.path, 'gossip.json'))
5151
52 + var status = {}
53 +
5254 //Known Peers
5355 var peers = []
5456
5557 function getPeer(id) {
@@ -57,8 +59,14 @@
5759 return e && e.key === id
5860 })
5961 }
6062
63 + server.status.hook(function (fn) {
64 + var _status = fn()
65 + _status.gossip = status
66 + return _status
67 + })
68 +
6169 server.close.hook(function (fn, args) {
6270 closed = true
6371 closeScheduler()
6472 for(var id in server.peers)
@@ -191,8 +199,9 @@
191199 //get current state
192200
193201 server.on('rpc:connect', function (rpc, isClient) {
194202 var peer = getPeer(rpc.id)
203 + status[rpc.id] = peer
195204 //don't track clients that connect, but arn't considered peers.
196205 //maybe we should though?
197206 if(!peer) {
198207 if(rpc.id !== server.id) {
@@ -227,8 +236,9 @@
227236 )
228237 }
229238
230239 rpc.on('closed', function () {
240 + delete status[rpc.id]
231241 console.log('Disconnected', stringify(peer))
232242 //track whether we have successfully connected.
233243 //or how many failures there have been.
234244 var since = peer.stateChange
plugins/replicate/legacy.jsView
@@ -347,4 +347,5 @@
347347 upto: upto,
348348 changes: notify.listen
349349 }
350350 }
351 +

Built with git-ssb-web