Socket
Socket
Sign inDemoInstall

rhea

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rhea - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

4

lib/connection.js

@@ -58,3 +58,5 @@ /*

if (config.host) options.host = config.host;
if (config.port) options.port = config.port;
if(config.port === 'amqp') options.port = 5762;
else if(config.port === 'amqps') options.port = 5761;
else options.port = config.port;
if (!(config.sasl && config.sasl.enabled === false)) {

@@ -61,0 +63,0 @@ if (config.user) options.username = config.user;

@@ -310,9 +310,7 @@ /*

var data;
var last = this.deliveries.get_tail();
if (last && last.incomplete) {
if (util.is_defined(frame.performative.delivery_id) && this.next_delivery_id !== frame.performative.delivery_id) {
//TODO: better error handling
throw Error('frame sequence error: delivery ' + this.next_delivery_id + ' not complete, got ' + frame.performative.delivery_id);
if (receiver._incomplete) {
current = receiver._incomplete;
if (util.is_defined(frame.performative.delivery_id) && current.id !== frame.performative.delivery_id) {
throw Error('frame sequence error: delivery ' + current.id + ' not complete, got ' + frame.performative.delivery_id);
}
current = last;
data = Buffer.concat([current.data, frame.payload], current.data.length + frame.payload.length);

@@ -348,2 +346,3 @@ } else if (this.next_delivery_id === frame.performative.delivery_id) {

this.deliveries.push(current);
this.next_delivery_id++;
data = frame.payload;

@@ -356,8 +355,9 @@ } else {

if (current.incomplete) {
receiver._incomplete = current;
current.data = data;
} else {
receiver._incomplete = undefined;
if (receiver.credit > 0) receiver.credit--;
else console.error('Received transfer when credit was %d', receiver.credit);
receiver.delivery_count++;
this.next_delivery_id++;
var msgctxt = current.format === 0 ? {'message':message.decode(data), 'delivery':current} : {'message':data, 'delivery':current, 'format':current.format};

@@ -364,0 +364,0 @@ receiver.dispatch('message', receiver._context(msgctxt));

{
"name": "rhea",
"version": "1.0.8",
"version": "1.0.9",
"description": "reactive AMQP 1.0 library",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/amqp/rhea",

@@ -18,6 +18,2 @@ [![Build Status](https://travis-ci.org/amqp/rhea.svg?branch=master)](https://travis-ci.org/amqp/rhea)

var container = require('rhea');
container.on('connection_open', function (context) {
context.connection.open_receiver('examples');
context.connection.open_sender('examples');
});
container.on('message', function (context) {

@@ -30,3 +26,5 @@ console.log(context.message.body);

});
container.connect({'port':5672});
var connection = container.connect({'port':5672});
connection.open_receiver('examples');
connection.open_sender('examples');
```

@@ -49,4 +47,4 @@

* [helloworld.js](examples/helloworld.js) - essentially the code above, which sends and receives
a single message through a broker
* [helloworld.js](examples/helloworld.js) - essentially the code above, which
sends and receives a single message through a broker

@@ -122,4 +120,4 @@ * [direct_helloworld.js](examples/direct_helloworld.js) - an example

library (this can be created e.g. by calling npm run-script
browserify or make browserify). The browserified and minimized javascript
library is stored under the dist/ directory.
browserify or make browserify). The browserified and minimized
javascript library is stored under the dist/ directory.

@@ -141,6 +139,7 @@ To run the examples you will need the dependencies installed: the

There are four core types of object in the API:
There are five core types of object in the API:
* <a href="#container">Containers</a>,
* <a href="#connection">Connections</a>,
* <a href="#session">Sessions</a>,
* <a href="#receiver">Receivers</a>,

@@ -152,5 +151,5 @@ * and <a href="#sender">Senders</a>

handled at sender or receiver scope are then propagated up to possibly
be handled at connection scope. Events that are not handled at
connection scope are then propagated up to possibly be handled at
container scope.
be handled at session scope. Events that are not handled at session
scope are then propagated up to possibly be handled at connection
scope, and if not there then in container scope.

@@ -224,10 +223,12 @@ Two other relevant objects are:

If options is undefined, the client will attempt to obtain default
options from a config file. This file is of similar structure to that
used by Apache Qpid Proton clients. The location of the file can be
specified through the MESSAGING_CONNECT_FILE environment variable. If
that is not specified it will look for a file called connect.json in
the current directory, in <home>/.config/messaging or /etc/messaging/.
options from a JSON config file. This file is of similar structure to
that used by Apache Qpid Proton clients. The location of the file can
be specified through the MESSAGING_CONNECT_FILE environment variable.
If that is not specified it will look for a file called connect.json
in the current directory, in <home>/.config/messaging or
/etc/messaging/.
The config file offers only limited configurability, specifically:
* scheme
* host

@@ -237,4 +238,7 @@ * port

* password
* sasl (a nested object with fields enabled and mechanisms)
* tls (a nested object with fields key, cert, ca and verify)
* sasl (a nested object with field enabled)
* sasl_mechanisms
* tls (a nested object with fields key, cert, ca for paths to
correspoding files)
* verify

@@ -371,4 +375,9 @@ ##### listen(options)

Provide information about the connection status. If it's opened or closed.
Provide information about the connection status. If it's opened or
closed.
##### create_session()
Creates a new session if you want to manage sessions by yourself.
#### events:

@@ -379,2 +388,3 @@

Raised when the remote peer indicates the connection is open.
This occurs also on reconnect.

@@ -384,2 +394,4 @@ ##### connection_close

Raised when the remote peer indicates the connection is closed.
This can happen either as a response to our close, or by itself.
The connection and sessions will not be reconnected.

@@ -390,23 +402,105 @@ ##### connection_error

specifies an error. A `connection_close` event will always follow this
event, so it only needs to be implemented if there are specific actions
to be taken on a close with an error as opposed to a close. The error
is available as a property on the event context.
event, so it only needs to be implemented if there are specific
actions to be taken on a close with an error as opposed to a close.
The error is available as a property on the event context.
If neither the connection_error or the connection_close is handled by
the application, an error event will be raised. This can be handled on
the connection or the container. If this is also unhandled, the
the application, an `error` event will be raised. This can be handled
on the connection or the container. If this is also unhandled, the
application process will exit.
##### protocol_error
Raised when a protocol error is received on the underlying socket.
A `disconnected` event will follow with any reconnect as configured.
##### error
Raised when an error is received on the underlying socket. This
catches any errors otherwise not handled.
##### disconnected
Raised when the underlying tcp connection is lost. The context has a
`reconnecting` property which is true if the library is attempting to
automatically reconnect and false if it has reached the reconnect
limit. If reconnect has not been enabled or if the connection is a tcp
server, then the `reconnecting` property is undefined. The context may
also have an `error` property giving some information about the reason
for the disconnect. If the disconnect event is not handled, a warning
will be logged to the console.
Raised when the underlying tcp connection is lost or nonfatal error
was received. The context has a `reconnecting` property which is true
if the library is attempting to automatically reconnect and false if
it has reached the reconnect limit. If reconnect has not been enabled
or if the connection is a tcp server, then the `reconnecting` property
is undefined. The context may also have an `error` property giving
some information about the reason for the disconnect. If the
disconnect event is not handled, a warning will be logged to the
console.
You should update the application state to resend any unsettled
messages again once the connection is recovered.
##### settled
Raised when remote settled the message.
---------------------------------------------------------------------
### Session
Session is an aggregation of <a href="#receiver">Receiver</a> and <a
href="#sender">Sender</a> links and provides the context and
sequencing of messages for all the links it contains. A <a
href="#connection">Connection</a> creates a default session for you if
you create receivers and senders on the Connection. You only need to
use this object if you want to group your links into more than one
session.
#### methods:
##### open_receiver(address|options)
This adds a receiver on the session. The `open_receiver` on the <a
href="#connection">Connection</a> object finds the session and calls
this.
##### open_sender(address|options)
This adds a sender on the session. The `open_sender` on the <a
href="#connection">Connection</a> object finds the session and calls
this.
##### close()
End a session (may take an error object which is an object that
consists of condition and description fields).
##### is_open()/is_closed()
Provide information about the session status. If it's opened or
closed.
#### events:
##### session_open
Raised when the remote peer indicates the session is open (i.e. begun
in AMQP parlance).
##### session_close
Raised when the remote peer indicates the session is closed (i.e.
ended in AMQP parlance). The session will be removed from the
connection after the event.
##### session_error
Raised when the remote peer indicates the session has ended and
specifies an error. A `session_close` event will always follow this
event, so it only needs to be implemented if there are specific
actions to be taken on a close with an error as opposed to a close.
The error is available as `error` property on the session object.
If neither the session_error or the session_close is handled by the
application, an `error` event will be raised on the container. If this
is also unhandled, the application process will exit.
##### settled
Raised when remote settled the message.
---------------------------------------------------------------------
### Receiver

@@ -418,4 +512,5 @@

Closes a receiving link (i.e. cancels the subscription). (May take an error object which is an object
that consists of condition and description fields).
Closes a receiving link (i.e. cancels the subscription). (May take an
error object which is an object that consists of condition and
description fields).

@@ -454,6 +549,28 @@ ##### detach()

##### receiver_drained
Raised when the remote peer indicates that it has drained all credit
(and therefore there are no more messages at present that it can send).
##### receiver_flow
Raised when a flow is received for receiver.
##### receiver_error
Raised when the remote peer closes the receiver with an error. A
`receiver_close` event will always follow this event, so it only needs
to be implemented if there are specific actions to be taken on a close
with an error as opposed to a close. The error is available as an
`error` property on the receiver.
##### receiver_close
Raised when the remote peer indicates the link is closed.
Raised when the remote peer indicates the link is closed (i.e.
detached in AMQP parlance).
##### settled
Raised when remote settled the message.
---------------------------------------------------------------------

@@ -466,4 +583,16 @@ ### Sender

Sends a <a href="#message">message</a>.
Sends a <a href="#message">message</a>. The link need not be yet open
nor is any credit needed, but there is a limit of 2048 deliveries in
the <a href="#session">Session</a> queue before it raises an exception
for buffer overflow.
Unsettled messages, whether transmitted or not, are lost on reconnect
and there will be no `accepted`, `released`, `rejected` events. You
may need to resend the messages on a `disconnected` event.
If the messages to be sent can be generated or fetched on demand or
there is large number of messages, it is recommended `send` is called
only while the sender is `sendable()`. When sender is no longer
sendable, continue sending in the `sendable` event.
##### close()

@@ -480,4 +609,10 @@

Returns true if the sender has available credits for sending a message. Otherwise it returns false.
Returns true if the sender has available credits for sending a
message. Otherwise it returns false.
##### set_drained(bool)
This must be called in response to `sender_draining` event to tell
peer we have drained our messages or credit.
#### events:

@@ -487,4 +622,5 @@

Raised when the sender has sufficient credit to be able to transmit
messages to its peer.
Raised when the sender has received credit to be able to transmit
messages to its peer. You will not receive a new event until the peer
sends more credit, even if you have some credit left.

@@ -502,3 +638,14 @@ ##### accepted

Raised when a sent message is rejected by the peer.
`context.delivery.remote_state.error` may carry diagnostics to explain
rejection, for example a `condition` property with value
`amqp:unauthorized-access`.
##### modified
Raised when a sent message is modified by the peer. The
`context.delivery.remote_state` may have `delivery_failed` and
`undeliverable_here` boolean and `message_annotations` map properties
to guide any message retransmission as specified in the AMQP 1.0
specification.
##### sender_open

@@ -509,6 +656,31 @@

##### sender_draining
Raised when the remote peer requests that the sender drain its credit;
sending all available messages within the credit limit and calling
`set_drained(true)`. After this the sender has no credit left.
##### sender_flow
Raised when a flow is received for sender. `sender_draining` and
`sendable` events may follow this event, so it only needs to be
implemented if there are specific actions to be taken.
##### sender_error
Raised when the remote peer closes the sender with an error. A
`sender_close` event will always follow this event, so it only needs
to be implemented if there are specific actions to be taken on a close
with an error as opposed to a close. The error is available as an
`error` property on the sender.
##### sender_close
Raised when the remote peer indicates the link is closed.
Raised when the remote peer indicates the link is closed (i.e.
detached in AMQP parlance).
##### settled
Raised when remote settled the message.
### Message

@@ -519,16 +691,31 @@

* durable
* first_acquirer
* priority
* ttl
* first_acquirer
* delivery_count
* reply_to
* delivery_annotations, an object/map of non-standard delivery
annotations sent to link recipient peer that should be negotiated
at link attach
* message_annotations, an object/map of non-standard delivery
annotations propagated accross all steps that should be negotiated
at link attach
* message_id
* user_id
* to
* subject
* reply_to
* correlation_id
* content_type
* content_encoding
* absolute_expiry_time
* creation_time
* group_id
* message_id
* correlation_id
* application_properties, an object/map which can take arbitrary, application defined named values
* body, which can be either a string, an object or a buffer
* group_sequence
* reply_to_group_id
* application_properties, an object/map which can take arbitrary,
application defined named simple values
* body, which can be of any AMQP type type or `data_section`,
`data_sections`, `sequence_section` or `sequence_sections` from
`rhea.message`.
* footer, an objec`t/map for HMACs or signatures or similar

@@ -553,4 +740,4 @@ Messages are passed to the send() method of Connection or Sender, and

* delivery_failed, if true the sender should increment the
delivery_count on the next redelivery attempt, if false it should
not
delivery_count on the next redelivery attempt, if false it
should not
* undeliverable_here, if true the sender should not try to

@@ -567,4 +754,3 @@ redeliver the same message to this receiver

---------------------------------------------------------------------
**Note: For detailed options and types, please refer to the type definitions
in the [typings](./typings) directory**.
**Note: For detailed options and types, please refer to the type
definitions in the [typings](./typings) directory**.

@@ -53,7 +53,11 @@ /// <reference types="node" />

*/
options: any;
options?: any;
/**
* @property {Function} connect The `connect` function of `"net"` or `"tls"` module.
*/
connect: Function;
connect?: Function;
/**
* @property {string} [transport] - The transport option.
*/
transport?: "tls" | "ssl" | "tcp";
}

@@ -92,3 +96,3 @@

/**
* @property {string} [transport] - The transport option.
* @property {string} [transport] - The transport option. This is ignored if connection_details is set.
*/

@@ -681,2 +685,2 @@ transport?: "tls" | "ssl" | "tcp";

settled = "settled"
}
}
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