Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions notifier/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (db *DB) FinishDB() {

// The first half of the transaction. WATCH the key and fetch its value.
// On error, UNWATCH the key.
func (db *DB) watchAndGet(key string) (interface{}, error) {
func (db *DB) watchAndGet(key string) (any, error) {
c, err := db.getPool()
if err != nil {
return nil, wrapErr(500, err)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (db *DB) unwatch() {
// WATCHed. Encode payload by json and write it then commit,
// or discard everything if any step fails. On success, returns
// what EXEC returns and nil. On error, returns nil and *appError.
func (db *DB) updateAndCommit(key string, payload interface{}) (interface{}, error) {
func (db *DB) updateAndCommit(key string, payload any) (any, error) {
c, err := db.getPool()
if err != nil {
return nil, wrapErr(500, err)
Expand Down Expand Up @@ -294,13 +294,13 @@ func (db *DB) GetChannels(appname string) (map[string]*Channel, error) {
if err != nil {
return nil, wrapErr(500, err)
}
ar, ok := r.([]interface{})
ar, ok := r.([]any)
if !ok {
return nil, appErr(500, fmt.Sprintf("redis SCAN returned weird value: %v", r))
}

next := string(ar[0].([]byte))
keys, ok := ar[1].([]interface{})
keys, ok := ar[1].([]any)
if !ok {
return nil, appErr(500, fmt.Sprintf("redis SCAN returned weird value: %v", r))
}
Expand Down
1 change: 0 additions & 1 deletion notifier/redis_init_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build redis_test
// +build redis_test

package notifier

Expand Down
1 change: 0 additions & 1 deletion notifier/redis_sentinel_init_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build redis_sentinel_test
// +build redis_sentinel_test

package notifier

Expand Down
1 change: 0 additions & 1 deletion notifier/redis_socket_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build chrome_test && redis_test
// +build chrome_test,redis_test

package notifier

Expand Down
1 change: 0 additions & 1 deletion notifier/redis_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build redis_test || redis_sentinel_test
// +build redis_test redis_sentinel_test

package notifier

Expand Down
14 changes: 7 additions & 7 deletions notifier/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ConnectionEstablishedData struct {
ActivityTimeout int `json:"activity_timeout"`
}

func encodePusherEvent(eventName string, chanName string, data interface{}) ([]byte, error) {
func encodePusherEvent(eventName string, chanName string, data any) ([]byte, error) {
s, ok := data.(string)
if !ok {
js, err := json.Marshal(data)
Expand Down Expand Up @@ -62,7 +62,7 @@ func (s *Supervisor) socketFinish(u *User, logmsg string, err error) {
_ = u.Connection.Close()
}

func (s *Supervisor) socketSend(u *User, eventName string, chanName string, data interface{}) {
func (s *Supervisor) socketSend(u *User, eventName string, chanName string, data any) {
msg, err := encodePusherEvent(eventName, chanName, data)
if err != nil {
s.socketFinish(u, "[internal] marshalling send packet error", err)
Expand All @@ -74,7 +74,7 @@ func (s *Supervisor) socketSend(u *User, eventName string, chanName string, data
}
}

func (s *Supervisor) socketSendInvalid(u *User, event string, received interface{}) {
func (s *Supervisor) socketSendInvalid(u *User, event string, received any) {
s.logger.Debugw("invalid event",
"event", event,
"data", received)
Expand Down Expand Up @@ -115,8 +115,8 @@ func (s *Supervisor) socketMessageHandleLoop(u *User) {
s.logger.Infow("received", "message", string(p))

var ev struct {
Name string `json:"event"`
Data interface{} `json:"data"`
Name string `json:"event"`
Data any `json:"data"`
}
err = json.Unmarshal(p, &ev)
if err != nil {
Expand All @@ -128,7 +128,7 @@ func (s *Supervisor) socketMessageHandleLoop(u *User) {
case "pusher:ping":
s.socketSend(u, "pusher:pong", "", "ok")
case "pusher:subscribe":
m, ok := ev.Data.(map[string]interface{})
m, ok := ev.Data.(map[string]any)
if !ok {
s.socketSendInvalid(u, ev.Name, ev.Data)
break
Expand All @@ -155,7 +155,7 @@ func (s *Supervisor) socketMessageHandleLoop(u *User) {
}
s.socketSend(u, "pusher_internal:subscription_succeeded", channel.(string), "ok")
case "pusher:unsubscribe":
m, ok := ev.Data.(map[string]interface{})
m, ok := ev.Data.(map[string]any)
if !ok {
s.socketSendInvalid(u, ev.Name, ev.Data)
break
Expand Down
1 change: 0 additions & 1 deletion notifier/socket_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build chrome_test
// +build chrome_test

package notifier

Expand Down
2 changes: 1 addition & 1 deletion notifier/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type getChannelResponse struct {
SubscriptionCount int `json:"subscription_count,omitempty"`
}

func returnJSON(w http.ResponseWriter, val interface{}) {
func returnJSON(w http.ResponseWriter, val any) {
js, err := json.Marshal(val)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down