Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
added defined(useSqliteTracker) for option to use
Browse files Browse the repository at this point in the history
SqliteTracker or not
  • Loading branch information
C-NERD committed Sep 17, 2022
1 parent b56c503 commit f4fa945
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/clown_limiter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@
spawn server()
sync()]##

import jester, clown_limiter/tracker
import jester
from re import re, contains, Regex

when not defined(useSqliteTracker):
## when not specified to use in memory sqlite to store tracking data

import clown_limiter/tracker

else:
## when specified to use in memory sqlite to store tracking data

import clown_limiter/sqlitetracker

export tracker, re

var clown_limiter_data_do_not_touch* : seq[tuple[pattern : Regex, rate, freq : int]] = @[
Expand Down Expand Up @@ -80,13 +90,13 @@ router clown_limiter:
rate = info.rate
freq = info.freq
break

if check_rate:

let
ip = request.ip()
rateinfo = ip.rateStatus(rate, freq)

case rateinfo.status

of Exceeded:
Expand All @@ -100,4 +110,3 @@ router clown_limiter:
of Expired:

ip.resetReqRate()

0 comments on commit f4fa945

Please sign in to comment.