Constructor
new StreamManagerClient(optsnullable)
Constructs a new Stream Manager client. Once connected, onConnectCb will be called and
the client can then be used.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<nullable> |
All these options are optional.
Properties
|
- Source:
Example
const { StreamManagerClient } = require('aws-greengrass-core-sdk/stream-manager');
const client = new StreamManagerClient();
c.onConnected(async () => {
// Do work with the client (c) here.
});
Methods
(async) appendMessage(streamName, data) → {Promise.<Number>}
Append a message into the specified message stream. Returns the sequence number of the message
if it was successfully appended.
Parameters:
Name | Type | Description |
---|---|---|
streamName |
string | The name of the stream to append to. |
data |
Buffer | Buffer containing the data to be written. |
- Source:
Returns:
- Type
- Promise.<Number>
close()
Close the connection
- Source:
(async) createMessageStream(definition) → {Promise.<void>}
Create a message stream with a given definition.
Parameters:
Name | Type | Description |
---|---|---|
definition |
aws-greengrass-core-sdk.StreamManager.MessageStreamDefinition |
- Source:
Returns:
- Type
- Promise.<void>
(async) deleteMessageStream(streamName) → {Promise.<void>}
Deletes a message stream based on its name. Nothing is returned if the request succeeds.
An error will be thrown if the request fails.
Parameters:
Name | Type | Description |
---|---|---|
streamName |
string | The name of the stream to be deleted. |
- Source:
Returns:
- Type
- Promise.<void>
(async) describeMessageStream(streamName) → {Promise.<aws-greengrass-core-sdk.StreamManager.MessageStreamInfo>}
Describe a message stream to get metadata including the stream's definition,
size, and exporter statuses.
Parameters:
Name | Type | Description |
---|---|---|
streamName |
string | The name of the stream to describe |
- Source:
Returns:
- Type
- Promise.<aws-greengrass-core-sdk.StreamManager.MessageStreamInfo>
(async) listStreams() → {Promise.<Array.<String>>}
List the streams in StreamManager. Returns a list of their names.
- Source:
Returns:
- Type
- Promise.<Array.<String>>
onConnected(f)
Add a callback for when the client connects.
Parameters:
Name | Type | Description |
---|---|---|
f |
function |
- Source:
onError(f)
Add a callback for when an error occurs.
Parameters:
Name | Type | Description |
---|---|---|
f |
function |
- Source:
(async) readMessages(streamName, optionsnullable) → {Promise.<Array.<aws-greengrass-core-sdk.StreamManager.Message>>}
Read message(s) from a chosen stream with options. If no options are specified it will try to read
1 message from the stream.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
streamName |
string | The name of the stream to read from. | ||
options |
aws-greengrass-core-sdk.StreamManager.ReadMessagesOptions |
<nullable> |
null | Options used when reading from the stream of type aws-greengrass-core-sdk.StreamManager.ReadMessagesOptions .
Defaults are:
If desiredStartSequenceNumber is specified in the options and is less than the current beginning of the stream, returned messages will start at the beginning of the stream and not necessarily the desiredStartSequenceNumber. |
- Source:
Returns:
List of one or more messages.
- Type
- Promise.<Array.<aws-greengrass-core-sdk.StreamManager.Message>>
(async) updateMessageStream(definition) → {Promise.<void>}
Updates a message stream with the new definition.
Minimum version requirements: StreamManager server version 1.1 (or AWS IoT Greengrass Core 1.11.0)
Parameters:
Name | Type | Description |
---|---|---|
definition |
aws-greengrass-core-sdk.StreamManager.MessageStreamDefinition |
- Source:
Returns:
- Type
- Promise.<void>