Methods
all() → {Promise.<Array.<string>>}
Returns a Promise that will resolve to all of the currently sent
message IDs (or reject if there is an error). This also clears
out any currently sent messages, so the next call to all()
will
be a clean slate.
Returns:
Type | Description |
---|---|
Promise.<Array.<string>> |
A Promise that resolves when all current messages are sent. |
publish(dataopt, attributesopt)
Publishes a message, subject to flow control restrictions.
If the message can be sent immediately, this will return null
. Otherwise,
it will return a Promise
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Buffer |
<optional> |
The message contents to be sent. |
attributes |
Attributes |
<optional> |
Optional attributes. |
Returns:
Type | Description |
---|---|
null, or a Promise that resolves when sending may resume. |
Examples
```
const wait = flowControlled.publish({data});
if (wait) {
await wait;
}
```
```
// It's okay to await unconditionally, it's equivalent to nextTick().
await flowControlled.publish(data);
```
publishNow(dataopt, attributesopt)
Publishes a message unconditionally, updating flow control counters.
You'll generally only want to use this if you want to deal with timing the flow control yourself, but you'd like the library to do the bean counting.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Buffer |
<optional> |
The message contents to be sent. |
attributes |
Attributes |
<optional> |
Optional attributes. |
wouldExceed(message) → {boolean}
Returns true if sending the specified Buffer would result in exceeding the limits of the flow control settings.
Parameters:
Name | Type | Description |
---|---|---|
message |
PubsubMessage |
The data buffer with the message's contents. |
Returns:
Type | Description |
---|---|
boolean |
True if the message would exceed flow control limits. |