oslabs-beta / GraphQL-Gate

A GraphQL rate limiting library with query complexity analysisfor Node.js

Home Page:http://graphqlgate.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Write spec for Sliding Window Log class

shalarewicz opened this issue · comments

With the FixedWindow algorithm, users are able to send more requests to go through at the edges of a window. The SlidingWindowLog algorithm addresses this issue by tracking request timestamps in in a log then removing these requests from the log once they fall outside of the window. If a request is received and there are more than capacity requests in the log then the request is dropped.

A spec for the SlidingWindowLog algorithm should be decided on prior to writing tests. The constructor should accept parameters for the following:

windowSize - Size of the window in milliseconds
capacity - number of requests allowed during each window
client - redis client instance

The SlidingWindowLog class must implement RateLimiter