refactor: Fix linter errors
This commit is contained in:
@@ -75,25 +75,21 @@ func (c *Connection) listenCloseNotify() {
|
|||||||
))
|
))
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
<-c.closeNotify
|
||||||
case <-c.closeNotify:
|
c.logger.Info("Trying to reconnect to rabbit")
|
||||||
c.logger.Info("Trying to reconnect to rabbit")
|
|
||||||
|
|
||||||
dial, dialErr := amqp.Dial(c.connString)
|
dial, dialErr := amqp.Dial(c.connString)
|
||||||
if dialErr != nil {
|
if dialErr != nil {
|
||||||
c.logger.Error("Error during reconnect try - ", dialErr)
|
c.logger.Error("Error during reconnect try - ", dialErr)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
c.conn = dial
|
|
||||||
c.closeNotify = dial.NotifyClose(make(chan *amqp.Error))
|
|
||||||
|
|
||||||
c.logger.Info("Rabbit connection stabilized")
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.conn = dial
|
||||||
|
c.closeNotify = dial.NotifyClose(make(chan *amqp.Error))
|
||||||
|
|
||||||
|
c.logger.Info("Rabbit connection stabilized")
|
||||||
|
|
||||||
time.Sleep(c.reconnectInterval)
|
time.Sleep(c.reconnectInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ContextKey string
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserContextKey ContextKey = "user"
|
||||||
|
)
|
||||||
|
|
||||||
func SetUserFromJWT() gin.HandlerFunc {
|
func SetUserFromJWT() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
ctx := c.Request.Context()
|
ctx := c.Request.Context()
|
||||||
@@ -34,7 +40,7 @@ func SetUserFromJWT() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, "user", user)
|
ctx = context.WithValue(ctx, UserContextKey, user)
|
||||||
|
|
||||||
c.Request = c.Request.WithContext(ctx)
|
c.Request = c.Request.WithContext(ctx)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user