Skip to content

Commit

Permalink
Analytics now a goroutine to speed up response time
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Buhr committed Jul 24, 2014
1 parent 689980b commit dfcb152
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion handler_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (e ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, err st
e.Spec.APIDefinition.APIID,
e.Spec.APIDefinition.OrgID,
OauthClientID}
analytics.RecordHit(thisRecord)
go analytics.RecordHit(thisRecord)
}

w.WriteHeader(errCode)
Expand Down
4 changes: 2 additions & 2 deletions handler_success.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func (s SuccessHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

thisSessionState := context.Get(r, SessionData).(SessionState)


thisRecord := AnalyticsRecord{
r.Method,
r.URL.Path,
Expand All @@ -67,7 +66,8 @@ func (s SuccessHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.Spec.APIDefinition.APIID,
s.Spec.APIDefinition.OrgID,
thisSessionState.OauthClientID}
analytics.RecordHit(thisRecord)

go analytics.RecordHit(thisRecord)
}

s.Proxy.ServeHTTP(w, r)
Expand Down
5 changes: 2 additions & 3 deletions storage_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (s InMemoryStorageManager) GetKeysAndValues() map[string]string {
return s.Sessions
}


// GetKeysAndValuesWithFilter does nothing here
func (s InMemoryStorageManager) GetKeysAndValuesWithFilter(filter string) map[string]string {
log.Warning("NOT IMPLEMENTED")
Expand Down Expand Up @@ -149,7 +148,7 @@ func (r *RedisStorageManager) cleanKey(keyName string) string {
func (r *RedisStorageManager) GetKey(keyName string) (string, error) {
db := r.pool.Get()
defer db.Close()
log.Info("Getting key: ", r.fixKey(keyName))
log.Debug("Getting key: ", r.fixKey(keyName))
if db == nil {
log.Info("Connection dropped, connecting..")
r.Connect()
Expand All @@ -171,7 +170,7 @@ func (r *RedisStorageManager) GetKey(keyName string) (string, error) {
func (r *RedisStorageManager) SetKey(keyName string, sessionState string, timeout int64) {
db := r.pool.Get()
defer db.Close()
log.Info("Setting key: ", r.fixKey(keyName))
log.Debug("Setting key: ", r.fixKey(keyName))
if db == nil {
log.Info("Connection dropped, connecting..")
r.Connect()
Expand Down

0 comments on commit dfcb152

Please sign in to comment.