Skip to content

Commit

Permalink
Fixed rate limiter bugs and hashing Analytics duplication entries
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Mar 20, 2015
1 parent e298cac commit 46d66e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions handler_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type ErrorHandler struct {
func (e ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, err string, errCode int) {

if config.StoreAnalytics(r) {

t := time.Now()

// Track the key ID if it exists
Expand All @@ -41,6 +42,9 @@ func (e ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, err st
if e.TykMiddleware.Spec.APIDefinition.Proxy.StripListenPath {
r.URL.Path = strings.Replace(r.URL.Path, e.TykMiddleware.Spec.Proxy.ListenPath, "", 1)
}

// This is an odd bugfix, will need further testing
r.URL.Path = "/" + r.URL.Path

OauthClientID := ""
thisSessionState := context.Get(r, SessionData)
Expand Down
8 changes: 4 additions & 4 deletions storage_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (r *RedisStorageManager) IncrememntWithExpire(keyName string, expire int64)
db := r.pool.Get()
defer db.Close()

log.Info("Incrementing raw key: ", keyName)
log.Debug("Incrementing raw key: ", keyName)
if db == nil {
log.Info("Connection dropped, connecting..")
r.Connect()
Expand All @@ -290,7 +290,7 @@ func (r *RedisStorageManager) IncrememntWithExpire(keyName string, expire int64)
// This function uses a raw key, so we shouldn't call fixKey
fixedKey := keyName
val, err := redis.Int64(db.Do("INCR", fixedKey))
log.Info("Incremented key: ", fixedKey, ", val is: ", val)
log.Debug("Incremented key: ", fixedKey, ", val is: ", val)
if val == 1 {
log.Info("--> Setting Expire")
db.Send("EXPIRE", fixedKey, expire)
Expand Down Expand Up @@ -430,7 +430,7 @@ func (r *RedisStorageManager) DeleteKeys(keys []string) bool {
asInterface[i] = interface{}(r.fixKey(v))
}

log.Info("Deleting: ", asInterface)
log.Debug("Deleting: ", asInterface)
_, err := db.Do("DEL", asInterface...)
if err != nil {
log.Error("Error trying to delete keys:")
Expand Down Expand Up @@ -459,7 +459,7 @@ func (r *RedisStorageManager) DeleteRawKeys(keys []string, prefix string) bool {
asInterface[i] = interface{}(prefix + v)
}

log.Info("Deleting: ", asInterface)
log.Debug("Deleting: ", asInterface)
_, err := db.Do("DEL", asInterface...)
if err != nil {
log.Error("Error trying to delete keys:")
Expand Down

0 comments on commit 46d66e5

Please sign in to comment.