mattpker / pm2-slack

A PM2 module to emit events to Slack
MIT License
145 stars 70 forks source link

New buffering algorithm #21

Closed ma-zal closed 6 years ago

ma-zal commented 6 years ago

Hello. I improved the buffering algorithm. Because I believe this is the good way, I'm offering it to original pm2-slack as pull request. You are welcome to discuss about it, of course!

Goals:

Implemented algorithm:

1) When new message comes, it is stored to buffer. Buffer starts to wait for interval buffer_seconds. 2) If any next messages comes in this interval, it will be also stored to buffer. Buffer will reset previous interval and starts to waiting for new buffer_seconds. 3) When no new message comes in interval buffer_seconds, buffer sends the messages to Slack channel. 4) To prevent buffer infinite cycling (when new messages are still received from some application), the buffer will forcibly send the buffered messages after buffer_max_seconds (default 60 seconds) interval.

mattpker commented 6 years ago

@ma-zal Thanks!

I added you as a collaborator to the github and npm repo's. Can you please pull this in and publish the new version?

ma-zal commented 6 years ago

Perfect, thanks! I will start working on it on Monday.

mattpker commented 6 years ago

@ma-zal Thanks for getting that in. Looks great!