ackintosh / ganesha

:elephant: A Circuit Breaker pattern implementation for PHP applications.
https://ackintosh.github.io/ganesha/
MIT License
585 stars 42 forks source link

MongoDB adapter - SlidingTimeWindow support #88

Open ahmad-elassuty opened 3 years ago

ahmad-elassuty commented 3 years ago

Thanks for this great package!

I'm a bit confused about MongoDB implementation. It is stated in the README that an adapter can support either SlidingTimeWindow or TumblingTimeWindow, however this is not the case for MongoDB adapter as far as I can tell from the implemented interfaces.

I believe MongoDB adapter does not support SlidingTimeWindow the same way Redis Adapter does. It rather resets the stats every whole time window (more like TumblingTimeWindow but without comparing to the previous window). I came to this conclusion after checking the adapter data model and the Rate strategy and I was wondering if that is by design or a bug?

ackintosh commented 3 years ago

Thank you for this issue! I'll take a look for this issue on this weekend. Sorry for keeping you waiting. 🙇

ackintosh commented 3 years ago

Oh it's a bug. 💦 You are completely right. The sliding timewindow implementation of MongoDB adapter is similar to TumblingTimeWindow but imperfect as you pointed.

I'll work on this but it may take some time because I'm not familiar with MongoDB.