fix lack of middleware in /go handler, also add tracing to session sweeper
This commit is contained in:
@@ -76,7 +76,7 @@ func setupEcho() *echo.Echo {
|
||||
e.GET("/venice/imagedata/:id", ui.AmServeVeniceCompatibleImage)
|
||||
}
|
||||
e.GET("/static/*", ui.AmStaticFileHandler())
|
||||
e.GET("/go/:postlink", ui.AmWrap(JumpToShortcut))
|
||||
e.GET("/go/:postlink", ui.AmWrap(JumpToShortcut), uiset...)
|
||||
|
||||
e.GET("/", ui.AmWrap(TopPage), uiset...)
|
||||
e.GET("/about", ui.AmWrap(AboutPage), uiset...)
|
||||
|
||||
+3
-1
@@ -242,7 +242,7 @@ func (sess *amSession) Hit() {
|
||||
sess.Set("lasthit", time.Now())
|
||||
}
|
||||
|
||||
// amSessionStore is the implementatiuon structure for AmSessionStore.
|
||||
// amSessionStore is the implementation structure for AmSessionStore.
|
||||
type amSessionStore struct {
|
||||
mutex sync.RWMutex
|
||||
sessions map[string]*amSession
|
||||
@@ -342,6 +342,7 @@ func (st *amSessionStore) SessionInfo() (int, []string, int) {
|
||||
func (st *amSessionStore) sweep(tick <-chan time.Time, done chan bool) {
|
||||
for range tick {
|
||||
if st.sweepRunning.Load() {
|
||||
log.Infof("session sweep running")
|
||||
// phase 1 - identify expired sessions
|
||||
st.mutex.RLock()
|
||||
zap := make([]string, 0, len(st.sessions))
|
||||
@@ -352,6 +353,7 @@ func (st *amSessionStore) sweep(tick <-chan time.Time, done chan bool) {
|
||||
}
|
||||
}
|
||||
st.mutex.RUnlock()
|
||||
log.Infof("identified %d sessions to zap", len(zap))
|
||||
|
||||
// phase 2 - get rid of the expired sessions
|
||||
for _, k := range zap {
|
||||
|
||||
Reference in New Issue
Block a user