Exemplo n.º 1
0
            /// <summary>
            /// Build a instance of RateLimitProcessor with some configurations
            /// </summary>
            /// <returns></returns>
            public RateLimitProcessor <TRequest> Build()
            {
                if (_storage == null)
                {
                    _storage = new InProcessMemoryStorage();
                }

                if (_algorithm == null)
                {
                    throw new ArgumentNullException("the algorithm can not be null.");
                }

                if (_error == null)
                {
                    _error = new RateLimitError();
                }

                return(new RateLimitProcessor <TRequest>(_storage, _algorithm, _error));
            }
Exemplo n.º 2
0
 /// <summary>
 /// create a new instance
 /// </summary>
 /// <param name="storage"></param>
 /// <param name="algorithm"></param>
 /// <param name="error"></param>
 private RateLimitProcessor(IRateLimitStorage storage, IRateLimitAlgorithm <TRequest> algorithm, RateLimitError error)
 {
     _algorithm = algorithm;
     _storage   = storage;
     _error     = error;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets a instance of RateLimitError
 /// </summary>
 /// <param name="error"></param>
 /// <returns></returns>
 public Builder WithError(RateLimitError error)
 {
     _error = error;
     return(this);
 }