logging: add new RateLimiter helper class
authorAdam Simpkins <simpkins@fb.com>
Thu, 15 Jun 2017 18:03:50 +0000 (11:03 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 15 Jun 2017 18:06:06 +0000 (11:06 -0700)
commitdc37f8eab5797e63c7cfe6f02de23518a40dcaa3
tree7e7fa2b612f2536a1de769c742373289e71de7d9
parent9578ff20cf9e4b30e6f2d8ffb082ed8ec9791042
logging: add new RateLimiter helper class

Summary:
Add a new RateLimiter API to the logging library, to support rate limiting
messages in the future.  I have included a single IntervalRateLimiter
implementation in this diff.  In the future we can add more implementations if
necessary, to mimic the functionality available with our older logging code, to
make it easier for users to convert to the new framework.

Note that RateLimiter is inside a `folly::logging` namespace, unlike most of
the other code in the logging library that lives directly in the `folly`
namespace.  I intentionally chose this since RateLimiter is a fairly generic
class name, and I wanted to distinguish it from other possible generic class
names in folly.  On the other hand, most of the other class names already start
with `Log`, so there seems to be no need to put them in a `logging` namespace.

Nothing is using this new API yet, but I will use it for some internal logging
APIs in an upcoming diff.  Later on I also plan to use it to implement
per-LogCategory rate limiting, and possibly per-LogHandler rate limiting.

Reviewed By: wez

Differential Revision: D5162805

fbshipit-source-id: 9b81c2f4544006cd392152a768296bce0c5daaa1
CMakeLists.txt
folly/Makefile.am
folly/experimental/logging/Makefile.am
folly/experimental/logging/RateLimiter.cpp [new file with mode: 0644]
folly/experimental/logging/RateLimiter.h [new file with mode: 0644]
folly/experimental/logging/test/RateLimiterTest.cpp [new file with mode: 0644]