ssbc / ssb-server

The gossip and replication server for Secure Scuttlebutt - a distributed social network
1.69k stars 164 forks source link

Moving plugins away from internal events #10

Closed pfrazee closed 10 years ago

pfrazee commented 10 years ago

Scuttlebot is meant to be imported into other projects, so it needs to be customizable. The plugins rely on internal events to coordinate, which I'd rather we exposed as an external API. Applications which import scuttlebot can then hook into the events and coordinate the plugins' APIs themselves.

For instance:

var server = sbot(config)
server.on('rpc-connection', function(rpc, rpcStream) {
  server.auth(rpc, { role: 'peer', ToS: 'be excellent to each other' }, function(err, res) {
    if (res.granted)
      server.syncFeeds(rpc)
  })
})
dominictarr commented 10 years ago

hmm... what about make the auth hard wired (not a plugin) and then call the actual plugins.

also, we could have the main export create something without any plugins activated yet.

pfrazee commented 10 years ago

Went ahead and made a PR. Take a look and tell me what you think

pfrazee commented 10 years ago

Addressed as a compromise: plugins now also export their APIs