Loads and maintains all transports
new (require("skyring/lib/transports"))(transports)
Parameters:
Name | Type | Description |
---|---|---|
transports |
TransportHandler | Array.<TransportHandler> | String | Array.<String> | Custom transports to register This can be a Transport class or a |
- Source:
Examples
const path = require('path') const Skyring = require('skyring') const kType = Symbol.for('SkyringTransport') class Fizzbuzz extends Skyring.Transport { constructor(opts) { super(opts) this.name = 'fizzbuzz' } exec (method, uri, payload, id, timer_store) { // send payload to uri... timer_store.success(id) } shutdown(cb) { // drain connections... // free up event loop cb() } static [Symbol.hasInstance](instance) { return instance[kType] === 'fizzbuzztransport' } get [Symbol.toStringTag]() { return 'FizzbuzzTransport' } get [kType]() { return 'fizzbuzztransport' } } const server = new Skyring({ transports: [ 'my-transport-module' , Fizzbuzz , path.resolve(__dirname, '../transports/fake-transport') ] })
const {Transports, Transport} = require('skyring') class Fizzbuzz extends Transport { constructor(opts) { super(opts) this.name = 'fizzbuzz' } exec (method, uri, payload, id, timer_store) { // send payload to uri... timer_store.remove(id) } shutdown(cb) { // drain connections... // free up event loop cb() } } const t = new Transports([ 'my-transport-module' , Fizzbuz , path.resolve(__dirname, '../transports/fake-transport') ])
Requires
- module:debug
- module:skyring/lib/transports/http
- module:skyring/conf
Type Definitions
-
TransportHandler(method, uri, Payload, id, storage)
-
Parameters:
Name Type Description method
String uri
String Payload
String id
String storage
LevelUp A levelup instance container all curring timer data
- Source: