Comparing version 0.8.4 to 0.8.10
@@ -0,1 +1,15 @@ | ||
/* | ||
* Copyright 2013-2018 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@@ -2,0 +16,0 @@ import events = require('events'); |
15
index.js
@@ -0,1 +1,16 @@ | ||
/* | ||
* Copyright 2013-2018 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
module.exports = require('./lib/nats'); |
120
lib/nats.js
@@ -1,6 +0,14 @@ | ||
/*! | ||
* Nats | ||
* Copyright(c) 2012-2017 Apcera Inc. All rights reserved. | ||
* Copyright(c) 2011-2014 Derek Collison (derek.collison@gmail.com) | ||
* MIT Licensed | ||
/* | ||
* Copyright 2013-2018 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@@ -24,3 +32,3 @@ | ||
*/ | ||
var VERSION = '0.8.4', | ||
var VERSION = '0.8.10', | ||
@@ -31,3 +39,3 @@ DEFAULT_PORT = 4222, | ||
MAX_CONTROL_LINE_SIZE = 512, | ||
MAX_CONTROL_LINE_SIZE = 1024, | ||
@@ -303,2 +311,12 @@ // Parser state | ||
}); | ||
// Randomize if needed | ||
if (options.noRandomize !== true) { | ||
shuffle(client.servers); | ||
} | ||
// if they gave an URL we should add it if different | ||
if(options.url !== undefined && client.servers.indexOf(options.url) === -1) { | ||
//make url first element so it is attempted first | ||
client.servers.unshift(new Server(url.parse(options.url))); | ||
} | ||
} else { | ||
@@ -310,7 +328,2 @@ if (undefined === options.url) { | ||
} | ||
// Randomize if needed | ||
if (options.noRandomize !== true) { | ||
shuffle(client.servers); | ||
} | ||
}; | ||
@@ -330,2 +343,9 @@ | ||
/** | ||
* @api private | ||
*/ | ||
Server.prototype.toString = function() { | ||
return this.url.href; | ||
}; | ||
/** | ||
* Properly select the next server. | ||
@@ -861,27 +881,4 @@ * We rotate the server list as we go, | ||
// Always try to read the connect_urls from info | ||
if (client.info.connect_urls && client.info.connect_urls.length > 0) { | ||
// don't add duplicates | ||
var known = []; | ||
client.servers.forEach(function(server) { | ||
known.push(server.url.href); | ||
}); | ||
// add new ones | ||
var toAdd = []; | ||
client.info.connect_urls.forEach(function(server) { | ||
var u = 'nats://' + server; | ||
if (known.indexOf(u) === -1) { | ||
toAdd.push(new Server(url.parse(u))); | ||
} | ||
}); | ||
client.processServerUpdate(); | ||
if (toAdd.length > 0) { | ||
if (client.options.noRandomize !== true) { | ||
shuffle(toAdd); | ||
} | ||
toAdd.forEach(function(s) { | ||
client.servers.push(s); | ||
}); | ||
} | ||
} | ||
// Process first INFO | ||
@@ -1013,2 +1010,53 @@ if (client.infoReceived === false) { | ||
/** | ||
* Process server updates in info object | ||
* @api internal | ||
*/ | ||
Client.prototype.processServerUpdate = function() { | ||
var client = this; | ||
if (client.info.connect_urls && client.info.connect_urls.length > 0) { | ||
// parse the infos | ||
var tmp = {}; | ||
client.info.connect_urls.forEach(function(server) { | ||
var u = 'nats://' + server; | ||
var s = new Server(url.parse(u)); | ||
// implicit servers are ones added via the info connect_urls | ||
s.implicit = true; | ||
tmp[s.url.href] = s; | ||
}); | ||
// remove implicit servers that are no longer reported | ||
var toDelete = []; | ||
client.servers.forEach(function(s, index) { | ||
var u = s.url.href; | ||
if(s.implicit && client.currentServer.url.href !== u && tmp[u] === undefined) { | ||
// server was removed | ||
toDelete.push(index); | ||
} | ||
// remove this entry from reported | ||
delete tmp[u]; | ||
}); | ||
// perform the deletion | ||
toDelete.reverse(); | ||
toDelete.forEach(function(index) { | ||
client.servers.splice(index, 1); | ||
}); | ||
// remaining servers are new | ||
var newURLs = []; | ||
for(var k in tmp) { | ||
if(tmp.hasOwnProperty(k)) { | ||
client.servers.push(tmp[k]); | ||
newURLs.push(k); | ||
} | ||
} | ||
if(newURLs.length) { | ||
// new reported servers useful for tests | ||
client.emit('serversDiscovered', newURLs); | ||
} | ||
} | ||
}; | ||
/** | ||
* Process a delivered message and deliver to appropriate subscriber. | ||
@@ -1015,0 +1063,0 @@ * |
{ | ||
"name": "nats", | ||
"version": "0.8.4", | ||
"version": "0.8.10", | ||
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", | ||
@@ -23,7 +23,6 @@ "keywords": [ | ||
}, | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"private": false, | ||
"author": { | ||
"name": "Derek Collison", | ||
"email": "derek@apcera.com" | ||
"name": "The NATS Authors" | ||
}, | ||
@@ -43,6 +42,6 @@ "contributors": [], | ||
"engines": { | ||
"node": ">= 0.10.x" | ||
"node": ">= 0.10.x <10.0.0" | ||
}, | ||
"dependencies": { | ||
"nuid": ">=0.6.8" | ||
"nuid": "^0.6.14" | ||
}, | ||
@@ -49,0 +48,0 @@ "devDependencies": { |
@@ -5,7 +5,7 @@ # NATS - Node.js Client | ||
[![license](https://img.shields.io/github/license/nats-io/node-nats.svg)](http://opensource.org/licenses/MIT) | ||
[![license](https://img.shields.io/github/license/nats-io/node-nats.svg)](https://www.apache.org/licenses/LICENSE-2.0) | ||
[![Travis branch](https://img.shields.io/travis/nats-io/node-nats/master.svg)]() | ||
[![Coveralls github branch](https://img.shields.io/coveralls/github/nats-io/node-nats/master.svg)]() | ||
[![npm](https://img.shields.io/npm/v/nats.svg)](https://www.npmjs.com/package/nats) | ||
[![npm](https://img.shields.io/npm/dt/nats.svg)](https://www.npmjs.com/package/nats) | ||
[![npm](https://img.shields.io/npm/dm/nats.svg)](https://www.npmjs.com/package/nats) | ||
@@ -51,3 +51,3 @@ ## Installation | ||
// `NATS` is the library. | ||
if(response.code && response.code === NATS.REQ_TIMEOUT) { | ||
if(response instanceof NATS.NatsError && response.code === NATS.REQ_TIMEOUT) { | ||
console.log('Request for help timed out.'); | ||
@@ -266,5 +266,36 @@ return; | ||
## Connect Options | ||
## Supported Node Versions | ||
The following is the list of connection options and default values. | ||
| Option | Aliases | Default | Description | ||
|-------- |--------- |--------- |------------ | ||
| `encoding` | | `"utf8"` | Encoding specified by the client to encode/decode data | ||
| `json` | | `false` | If true, message payloads are converted to/from JSON | ||
| `maxPingOut` | | `2` | Max number of pings the client will allow unanswered before rasing a stale connection error | ||
| `maxReconnectAttempts` | | `10` | Sets the maximun number of reconnect attempts. The value of `-1` specifies no limit | ||
| `name` | `client` | | Optional client name | ||
| `noRandomize` | `dontRandomize`, `NoRandomize` | `false` | If set, the order of user-specified servers is randomized. | ||
| `pass` | `password` | | Sets the password for a connection | ||
| `pedantic` | | `false` | Turns on strict subject format checks | ||
| `pingInterval` | | `120000` | Number of milliseconds between client-sent pings | ||
| `preserveBuffers` | | `false` | If true, data for a message is returned as Buffer | ||
| `reconnect` | | `true` | If false server will not attempt reconnecting | ||
| `reconnectTimeWait` | | `2000` | If disconnected, the client will wait the specified number of milliseconds between reconnect attempts | ||
| `servers` | `urls` | | Array of connection `url`s | ||
| `tls` | `secure` | `false` | This property can be a boolean or an Object. If true the client requires a TLS connection. If false a non-tls connection is required. The value can also be an object specifying TLS certificate data. The properties `ca`, `key`, `cert` should contain the certificate file data. `ca` should be provided for self-signed certificates. `key` and `cert` are required for client provided certificates. `rejectUnauthorized` if `true` validates server's credentials | ||
| `token` | | | Sets a authorization token for a connection | ||
| `url` | `uri` | `"nats://localhost:4222"` | Connection url | ||
| `useOldRequestStyle` | | `false` | If set to `true` calls to `request()` and `requestOne()` will create an inbox subscription per call. | ||
| `user` | | | Sets the username for a connection | ||
| `verbose` | | `false` | Turns on `+OK` protocol acknowledgements | ||
| `waitOnFirstConnect` | | `false` | If `true` the server will fall back to a reconnect mode if it fails its first connection attempt. | ||
| `yieldTime` | | | If set, processing will yield at least the specified number of milliseconds to IO callbacks before processing inbound messages | ||
## Supported Node Versions | ||
Support policy for Nodejs versions follows | ||
@@ -278,24 +309,2 @@ [Nodejs release support]( https://github.com/nodejs/Release). | ||
(The MIT License) | ||
Copyright (c) 2018 Synadia Communications Inc.<br/> | ||
Copyright (c) 2015-2017 Apcera Inc.<br/> | ||
Copyright (c) 2011-2015 Derek Collison | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81341
8
1684
307
+ Addednuid@0.6.14(transitive)
- Removednuid@2.0.0(transitive)
Updatednuid@^0.6.14