Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pull-handshake

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-handshake

easily create a duplex protocol that starts with a handshake

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

pull-handshake

Make a duplex protocol that starts with a handshake.

Writing duplex protocols are difficult. (don't get me started on "callback hell", that is nothing) This module implements the boiler plate for a duplex protocol where a handshake is exchanged (and calculating the handshake can be async)

The basic outline for the sort of protocol you can build with pull-handshake is as follows:

  1. two entities (databases, etc) connect via a stream.
  2. each retrives some meta information (asyncly) and sends that to the other side.
  3. when each node has both retrived it's own metadata, and recieved the remote data, that is compared - and the node determins what data must be sent, and what to do with the data that is expected to be received.
handshake(function (cb) {
  //callback with your metadata
  getMyMetadata(cb)
}, function (me, you) {
  //compare my header with your header and decide what to send.
  var missing = findDifference(me, you)

  //return a duplex pull-stream, that handles both reading and writing.
  return {
    source: createReadStream(missing)
    sink: createWriteStream()
  }
})

see pull-2step-replicate for a working example.

License

MIT

FAQs

Package last updated on 11 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc