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
|
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. |
Returns:
- Type
- Promise.<Number>
close()
Close the connection
(async) createMessageStream(definition) → {Promise.<void>}
Create a message stream with a given definition.
Parameters:
Name | Type | Description |
---|---|---|
definition |
aws-greengrass-core-sdk.StreamManager.MessageStreamDefinition |
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. |
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 |
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.
Returns:
- Type
- Promise.<Array.<String>>
onConnected(f)
Add a callback for when the client connects.
Parameters:
Name | Type | Description |
---|---|---|
f |
function |
onError(f)
Add a callback for when an error occurs.
Parameters:
Name | Type | Description |
---|---|---|
f |
function |
(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. |
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 |
Returns:
- Type
- Promise.<void>