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("/venice/imagedata/:id", ui.AmServeVeniceCompatibleImage)
|
||||||
}
|
}
|
||||||
e.GET("/static/*", ui.AmStaticFileHandler())
|
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("/", ui.AmWrap(TopPage), uiset...)
|
||||||
e.GET("/about", ui.AmWrap(AboutPage), uiset...)
|
e.GET("/about", ui.AmWrap(AboutPage), uiset...)
|
||||||
|
|||||||
+3
-1
@@ -242,7 +242,7 @@ func (sess *amSession) Hit() {
|
|||||||
sess.Set("lasthit", time.Now())
|
sess.Set("lasthit", time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
// amSessionStore is the implementatiuon structure for AmSessionStore.
|
// amSessionStore is the implementation structure for AmSessionStore.
|
||||||
type amSessionStore struct {
|
type amSessionStore struct {
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
sessions map[string]*amSession
|
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) {
|
func (st *amSessionStore) sweep(tick <-chan time.Time, done chan bool) {
|
||||||
for range tick {
|
for range tick {
|
||||||
if st.sweepRunning.Load() {
|
if st.sweepRunning.Load() {
|
||||||
|
log.Infof("session sweep running")
|
||||||
// phase 1 - identify expired sessions
|
// phase 1 - identify expired sessions
|
||||||
st.mutex.RLock()
|
st.mutex.RLock()
|
||||||
zap := make([]string, 0, len(st.sessions))
|
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()
|
st.mutex.RUnlock()
|
||||||
|
log.Infof("identified %d sessions to zap", len(zap))
|
||||||
|
|
||||||
// phase 2 - get rid of the expired sessions
|
// phase 2 - get rid of the expired sessions
|
||||||
for _, k := range zap {
|
for _, k := range zap {
|
||||||
|
|||||||
Reference in New Issue
Block a user