Module: skyring/lib/server

Primary server instance for a skyring app.


new (require("skyring/lib/server"))( [options])

Extends:
  • http.Server
Parameters:
Name Type Argument Default Description
options Object <optional>
Properties
Name Type Argument Description
node module:skyring/lib/server/node <optional>

A customer node instance

optiopns.node.host String <optional>

host name for the node to listen on - 127.0.0.1 must be used for localhost ( not 0.0.0.0 )

options.node.port Number <optional>

Port number for the node to listen on in the ring

options.node.app String <optional>
timers

name of the active ring to join

options.nats Object <optional>
Properties
Name Type Argument Description
servers Array.<String> <optional>

An array of nats host:port addresses to connect to

options.transports Array.<String> | Array.<function()> <optional>

an array of custom transport functions, or requireable paths that resolve to functions. All transport function must be named functions

Since:
  • 1.0.0
Author:
  • Eric Satterwhite
Source:
Examples
// Use only configuration values
var server = new Server().listen(5000)
var server = new Server({
  node :{
    host: 172.17.0.9
  , port: 8456
  , app: 'payback'
  }
, nats: {
    servers: ['nats1.domain.com:4222', 'nats2.domain.com:4222']
  }
})
server.listen(5000)
// Use a custom node instance
var node = new Node({
    host: 172.17.0.9
  , port: 8456
  , app: 'payback'
})
var server = new Server({ node })
server.listen(5000)

Requires

Methods


close(callback)

Removes a server from the ring, closes the http server and redistributes any pending timers

Parameters:
Name Type Description
callback function

A callback to be called when the server is completely shut down

Source:

listen(port [, host] [, backlog] [, callback])

Joins the node to the configured ring and starts the http server

Parameters:
Name Type Argument Default Description
port Number

Port number to listen on

host String <optional>
localhost

host or ip address to listen on

backlog Number <optional>
callback function <optional>

Callback function to call when the server is running

Source:
Returns:
Type
module:skyring/lib/server