The credentials that a session uses to authenticate itself.
When running the Diffusion Client in a browser context, access to the
Buffer
api is made available through {@link diffusion.buffer}.
Alias for the JSON interface to keep compatibility with old TypeScript definitions
Alias for the JSONDataType interface to keep compatibility with old TypeScript definitions
Alias for the MessageSendResult interface to keep compatibility with old TypeScript definitions
Alias for the Options interface to keep compatibility with old TypeScript definitions
A callback function type for Streams
Alias for the TopicUpdateHandler interface to keep compatibility with old TypeScript definitions
Emitted when the Stream has been closed through completion or the underlying session has been closed. No further events will be emitted after this.
Emitted when an error occurs in the Stream or in any of its listeners. No further events will be emitted after this.
the error that occurred
Access to the Buffer API that is packaged with diffusion.
This can be used in browsers that don't have a native Buffer class. It allows the creation of buffers for use with binary datatypes.
Allocates a new buffer containing the given {str}.
String to store in buffer.
encoding to use, optional. Default is 'utf8'
Allocates a new buffer of {size} octets.
count of octets to allocate.
Allocates a new buffer containing the given {array} of octets.
The octets to store.
Produces a Buffer backed by the same allocated memory as the given {ArrayBuffer}.
The ArrayBuffer with which to share memory.
Allocates a new buffer containing the given {array} of octets.
The octets to store.
Copies the passed {buffer} data onto a new {Buffer} instance.
The buffer to copy.
This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
Allocates a new buffer of {size} octets.
count of octets to allocate.
if specified, buffer will be initialized by calling buf.fill(fill). If parameter is omitted, buffer will be filled with zeros.
encoding used for call to buf.fill while initalizing
Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents of the newly created Buffer are unknown and may contain sensitive data.
count of octets to allocate
Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents of the newly created Buffer are unknown and may contain sensitive data.
count of octets to allocate
Gives the actual byte length of a string. encoding defaults to 'utf8'. This is not the same as String.prototype.length since that returns the number of characters in a string.
string to test. (TypedArray is also allowed, but it is only available starting ES2017)
encoding used to evaluate (defaults to 'utf8')
The same as buf1.compare(buf2).
Returns a buffer which is the result of concatenating all the buffers in the list together.
If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. If the list has exactly one item, then the first item of the list is returned. If the list has more than one item, then a new Buffer is created.
An array of Buffer objects to concatenate
Total length of the buffers when concatenated. If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray. The optional {byteOffset} and {length} arguments specify a memory range within the {arrayBuffer} that will be shared by the Buffer.
The .buffer property of a TypedArray or a new ArrayBuffer()
Creates a new Buffer using the passed {data}
data to create a new Buffer
Creates a new Buffer containing the given JavaScript string {str}. If provided, the {encoding} parameter identifies the character encoding. If not provided, {encoding} defaults to 'utf8'.
Returns true if {obj} is a Buffer
object to test.
Returns true if {encoding} is a valid encoding argument. Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
string to test.
The build version of this client library
Access to PropertyKeys
Access to the datatypes namespace
The ErrorReason enum
Valid TopicSpecification keys
Access to the locks namespace
Access to the selectors namespace
Access to the topicUpdate namespace
Access to the topics namespace
The version of this client library in the form major.minor.patch
Connect to a specified Diffusion server. This will return a Result that will complete succesfully if a session can be connected, or fail if an error was encountered.
If the result is succesful, the fulfilled handler will be called with a Session instance. This session will be in a connected state and may be used for subsequent API calls.
If the result fails, the rejected handler will be called with an error reason.
Example:
diffusion.connect('example.server.com').then(function(session) {
// Connected with a session
console.log('Connected!', session);
}, function(error) {
// Connection failed
console.log('Failed to connect', error);
});
the options to construct the session with.
a Result for this operation
Escapes special characters in a string that is to be used within a topic property or a session filter.
This is a convenience method which inserts an escape character '' before any of the special characters ' " or .
the string to be escaped
the string value with escape characters inserted as appropriate
Set the level of logging used by Diffusion. This will default to silent. Log levels are strings that represent different degrees of information to be logged. Available options are:
the log level to use
Utility method which converts a string of the format required by the $Roles session property into a mutable set of strings.
the string with quoted roles separated by whitespace or commas
set of roles
Returns an update constraint factory.
update constraint factory
Value returned by Session.getPrincipal if no principal name is associated with the session.
Dictionary containing standard session property keys
Example:
// Get the ALL_FIXED_PROPERTIES key
var props = diffusion.clients.PropertyKeys.ALL_FIXED_PROPERTIES;
Example:
// Get all user and fixed properties
var props = diffusion.clients.PropertyKeys.ALL_FIXED_PROPERTIES
.concat(diffusion.clients.PropertyKeys.ALL_USER_PROPERTIES);
Enum representing the reason that the session has been closed.
Example:
diffusion.connect({...}).then(function(session) {...}, function(err) {
switch(err) {
case diffusion.clients.CloseReason.CLOSED_BY_CLIENT:
// Do something
case diffusion.clients.CloseReason.ACCESS_DENIED:
// Do something else
...
}
});
The connection attempt failed due to a security restraint.
The session has been closed by the client.
The session has been closed by the server, or another session using the ClientControl feature.
The client could not establish a connection to the server.
The connection attempt timed out.
There was an error parsing the handshake response - usually indicative of incompatible protocol versions.
The connection handshake was rejected by the server.
The client detected that the connection was idle.
Message loss after reconnection has been detected.
Whilst disconnected, the client explicitly aborted a reconnect attempt/
There was an unexpected error with the network connection.
Enum containing reason codes used to report error conditions.
Some common ErrorReason values are defined as global constants. More specific reasons may be defined by individual features.
Example:
// Handle an error from the server
session.addStream('foo', diffusion.datatypes.string()).on('error', function(e) {
if (e == diffusion.errors.ACCESS_DENIED) {
// Handle authorisation error
} else {
// Log the problem
console.log(e);
}
});
The request was rejected because the caller has insufficient permissions.
An application callback threw an exception. Check logs for more information.
Communication with the server failed.
A conflicting registration exists on the server.
An operation failed due to using an incompatible data type.
An operation failed because invalid data was received.
An invalid path was supplied.
An operation failed because an addressed session could not be found.
A recipient session has rejected a received message request.
Communication with the server failed because a service request timed out.
Communication with the server failed because the session is closed.
A conflicting registration exists on the same branch of the topic tree.
A sent message was not handled by the specified recipient.
The request was rejected because the requested operation is unsupported for this caller.
The reason that a topic could not be added.
Example:
session.topics.add('foo').then(function() { ... }, function(err) {
switch (err) {
case diffusion.topics.TopicAddFailReason.EXISTS:
...
case diffusion.topics.TopicAddFailReason.INVALID_PATH:
...
}
});
When trying to create the topic the cluster was migrating the partition that owns the topic. The correct owner could not be identified and the request failed. This is a transient failure for the duration of the partition migration.
Adding the topic failed because of a license limit.
The topic already exists with the same details.
Adding the topic failed because a topic is already bound to the specified path but the caller does not have the rights to manage it.
This can be because the topic is being managed by a component with exclusive control over the topic, such as fan-out or a publisher and thus the caller will not be able to update or remove the topic.
If the caller has suitable permissions then it could still subscribe to the topic, but the topic's specification may be different from that requested.
The topic already exists, with different details.
Adding a slave topic failed because a topic owned by a publisher is already bound to the specified master path.
Adding the topic failed because a topic owned by a publisher is already bound to the parent path.
The topic could not be initialised, supplied value may be of the wrong format. Deprecation notice
This value is associated only with removed methods that allow the specification of an initial value when creating a topic. It will be removed in a future release.
The topic details are invalid.
The supplied topic path is invalid.
The topic path is invalid.
Invalid permissions to add a topic at the specified path.
A referenced topic could not be found.
An unexpected error occured while creating the topic.
A user supplied class could not be found or instantiated. Deprecation notice
This value is associated only with removed methods that create topics. It will be removed in a future release.
Enum containing possible Topic Types.
Example:
// Get a topic type for adding topics
var topicType = diffusion.topics.TopicType.JSON;
session.topics.add("foo", topicType);
Binary Topic.
This is a stateful topic that handles data in Binary format.
Topic that stores and publishes IEEE 754 double-precision floating point numbers (i.e native JavaScript Numbers). Based on the double data type.
Supports null Double values.
The topic does not support delta-streams - only complete values are transmitted.
Topic that stores and publishes 64-bit integer values. Based on the int64 data type. Values are of the type Int64.
Supports null int64 values.
Does not support delta-streams - only complete values are transmitted.
JSON (JavaScript Object Notation) Topic.
This is a stateful topic that handles data in JSON representation.
Topic that stores and publishes data in the form of records and fields. Based on the RecordV2 data type.
Supports delta-streams.
Routing Topic.
A functional topic that can point to different target topics for different clients.
From the point of view of a client subscribing to such a topic this would be seen as a normal stateful topic but it has no state of its own and cannot be published to.
Such a topic may specify a user written Java class which will be invoked to define the mapping of the topic to another data topic when a client subscribes. Alternatively the mapping can be delegated to a control client using the SubscriptionControl feature.
Slave Topic.
A topic that references another topic (the master topic) which has data (i.e. an alias). It effectively allows a topic's data to be shared across more than one topic node.
A client cannot tell that it is subscribed to a slave topic. A client requesting details of a slave topic will receive the details of the master topic. A client subscribing to the slave topic will receive all updates to the master topic. The slave topic itself may not be updated.
Any number of slave topics may reference the same master topic.
If a topic is removed that referenced by slave topics, all such slave topics are also automatically removed.
Slave topics are unable to be created by the Javascript client, but may safely be subscribed to.
Topic that stores and publishes String values. Based on the string data type.
Supports null String values.
Supports delta-streams.
Time Series Topic.
A time series is a sequence of events. Each event contains a value and has server-assigned metadata comprised of a sequence number, timestamp, and author.
A time series topic allows sessions to access a time series that is
maintained by the server. A time series topic has an associated
event data type, such as Binary
, String
,
or JSON
, that determines the type of value associated with each
event.
The TIME_SERIES_SUBSCRIPTION_RANGE property configures the range of historic events retained by a time series topic. If the property is not specified, a time series topic will retain the ten most recent events.
The TIME_SERIES_SUBSCRIPTION_RANGE property configures a time series topic to send a range of historic events from the end of the time series to new subscribers. This is a convenient way to synchronize new subscribers without requiring the use of a range query.
By default, new subscribers will be sent the latest event if delta streams are enabled and no events if delta streams are disabled. See the description of Subscription range in the Session.timeseries time series feature} documentation.
The TIME_SERIES_EVENT_VALUE_TYPE property must be provided when creating a time series topic.
A topic type that is unsupported by the session.
Enum containing reasons that an unsubscription occurred.
Example:
// Use UnsubscribeReason to validate unsubscription notifications
session.addStream('>foo', diffusion.datatypes.string())
.on('unsubscribe', function(topic, specification, reason) {
switch (reason) {
case diffusion.topics.UnsubscribeReason.REMOVED :
// Do something if the topic was removed
default :
// Do something else if the client was explicitly unsubscribed
}
});
The unsubscription occurred because the session is no longer authorized to access the topic.
The server has a significant backlog of messages for the session, and the topic specification has the conflation topic property set to 'unsubscribe'. The session can resubscribe to the topic. The unsubscription is not persisted to the cluster. If the session fails over to a different server it will be resubscribed to the topic.
The server or another client unsubscribed this client.
The topic was removed
The unsubscription was requested by this client.
A fallback stream has been unsubscribed or subscribed due to the addition or removal of a stream that selects the topic.
The server has re-subscribed this session to the topic. Existing streams are unsubscribed because the topic type and other attributes may have changed.
This can happen if a set of servers are configured to use session replication, and the session connected to one server reconnects ('fails over') to a different server.
A stream that receives an unsubscription notification with this reason will also receive a subscription notification with the new TopicSpecification.
A reason that is unsupported by the session.
The reason that a topic could not be updated.
Example:
session.topics.update('foo', 'bar').then(function() { ... }, function(err) {
switch (err) {
case diffusion.topics.UpdateFailReason.MISSING_TOPIC:
...
case diffusion.topics.UpdateFailReason.EXCLUSIVE_UPDATER_CONFLICT:
...
}
});
An update to a replicated topic failed because the cluster was repartitioning due to a server starting, stopping, or failing. The session can retry the operation.
An attempt has been made to apply a delta to a topic that has not yet has a value specified for it.
Violation of content duplication restrictions.
Attempt to perform a non-exclusive update to a topic branch that already has an update source registered to it.
An update could not be performed because the topic is managed by a component (e.g fan-out) that prohibits updates from the caller.
The update was of a type that is not compatible with the topic it was submitted for, or the topic does not support updating.
Invalid key or index used for addressing topic content.
The updater used is not active.
The topic being updated does not exist.
The update failed, possibly because the content sent with the update was invalid/incompatible with topic type or data format.
Action to be taken by the system authentication handler for connection attempts that do not provide a principal name and credentials.