Skip to content

Commit 8a0ed77

Browse files
authored
New buffering algorithm (#21)
Message bufferring refactored. Message grouping refactored. Added datetime parsing from log messages.
1 parent 1fdfec9 commit 8a0ed77

File tree

4 files changed

+306
-112
lines changed

4 files changed

+306
-112
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,31 @@ pm2 set pm2-slack:error false
4242
The following options are available:
4343

4444
- username (string) - Set the username used in Slack for posting the message. By default this is the hostname of the server.
45-
- buffer (bool) - Enable/Disable buffering of messages by timestamp. Messages that occur with the same timestamp (seconds) will be concatenated together and posted as a single slack message. Default: true
46-
- buffer_seconds (int) - Duration in seconds to aggregate messages. Has no effect if buffer is set to false. Min: 1, Max: 5, Default: 1
47-
- queue_max (int) - Number of messages to keep queued before the queue will be truncated. When the queue exceeds this maximum, a rate limit message will be posted to slack. Min: 10, Max: 100, Default: 100
45+
- buffer (bool) - Enable/Disable buffering of messages. Messages that occur in short time will be concatenated together and posted as a single slack message. Default: true
46+
- buffer_seconds (int) - If buffering is enables, all messages are stored for this interval. If no new messages comes in this interval, buffered message(s) are sended to Slack. If new message comes in this interval, the "timer" will be reseted and buffer starts waiting for the new interval for a new next message. *Note: Puspose is reduction of push notifications on Slack clients.* Default: 2
47+
- buffer_max_seconds (int) - If time exceed this time, the buffered messages are always sent to Slack, even if new messages are still comming in interval (property `buffer_seconds`). Default: 20
48+
- queue_max (int) - Maximum number of messages, that can be send in one Slack message (in one bufferring round). When the queue exceeds this maximum, next messages are suppresesed and replaced with message "`Next XX messages have been suppressed.`". Default: 100
4849

4950
Set these options in the same way you subscribe to events.
5051

51-
Example: The following configuration options will enable message buffering, and set the buffer duration to 2 seconds. All messages that occur within 2 seconds of each other (for the same event) will be concatenated into a single slack message.
52+
Example: The following configuration options will enable message buffering, and set the buffer duration to 5 seconds. All messages that occur within maximum 5 seconds delay between two neighboring messages will be concatenated into a single slack message.
5253

5354
```
5455
pm2 set pm2-slack:username pm2-user
55-
pm2 set pm2-slack:buffer true
56-
pm2 set pm2-slack:buffer_seconds 2
56+
pm2 set pm2-slack:buffer_seconds 5
5757
```
5858

59+
Note: In this example, the maximum total delay for messages is still 20 seconds (default value for `buffer_max_seconds`). After this time, the buffer will be flushed
60+
everytime and all messages will be sent.
61+
62+
5963
## Contributing
6064

6165
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
6266

6367
## Release History
64-
68+
- 1.0.0 Message bufferring refactored. Message grouping refactored.
69+
Added datetime parsing from log messages.
6570
- 0.3.4 Added an option to override the Slack username
6671
- 0.3.3 Added documentation for the reload event
6772
- 0.3.2 Fixed Half width of error and log messages (thanks @ma-zal)

0 commit comments

Comments
 (0)