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

interface-connection

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interface-connection

A test suite and interface you can use to implement a connection interface.

  • 0.1.8
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

interface-connection

A test suite and interface you can use to implement a connection. A connection is understood as something that offers mechanism for writing and reading data, back pressure, half and full duplex streams. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer.

The primary goal of module is to enable developers to pick, swap or upgrade their connection without loosing the same API expectations and mechanisms such as back pressure and the hability to half close a connection.

Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.

The API is presented with both Node.js and Go primitives, however, there is not actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through diferent stacks.

Modules that implement the interface

Badge

Include this badge in your readme if you make a module that is compatible with the interface-connection API. You can validate this by running the tests.

How to use the battery of tests

Node.js

var tape = require('tape')
var tests = require('interface-connection/tests')
var YourConnectionHandler = require('../src')

var common = {
  setup: function (t, cb) {
    cb(null, YourConnectionHandler)
  },
  teardown: function (t, cb) {
    cb()
  }
}

tests(tape, common)

Go

WIP

API

A valid (read: that follows this abstraction) connection, must implement the following API.

Table of contents:

  • type: Connection
    • conn.getObservedAddrs(callback)
    • conn.getPeerInfo(callback)
    • conn.setPeerInfo(peerInfo)
    • conn.destroy
    • conn.write
    • conn.read
    • conn.pipe
    • conn.end
    • conn.pause
    • conn.resume
    • conn.destroy
    • ...

Get the Observed Addresses of the peer in the other end

  • JavaScript - conn.getObservedAddrs(callback)

This method retrieves the observed addresses we get from the underlying transport, if any.

callback should follow the follow function (err, multiaddrs) {}, where multiaddrs is an array of multiaddr.

Get the PeerInfo

  • JavaScript - conn.getPeerInfo(callback)

This method retrieves the a Peer Info object that contains information about the peer that this conn connects to.

callback should follow the function (err, peerInfo) {} signature, where peerInfo is a object of type Peer Info

Set the PeerInfo

  • JavaScript - conn.setPeerInfo(peerInfo) j This method stores a reference to the peerInfo Object that contains information about the peer that this conn connects to.

peerInfo is a object of type Peer Info


notes:

  • should follow the remaining Duplex stream operations
  • should have backpressure into account
  • should enable half duplex streams (close from one side, but still open for the other)
  • should support full duplex
  • tests should be performed by passing two streams

Keywords

FAQs

Package last updated on 03 Aug 2016

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