Skip to content

Commit

Permalink
MM-60439: Set websocket scope early
Browse files Browse the repository at this point in the history
Because there is a return statement which gets executed
if the user isn't part of any teams, this optimization
won't kick in if that's the case.

To let the optimization happen in all cases, we move the
line earlier.

https://mattermost.atlassian.net/browse/MM-60439
  • Loading branch information
agnivade committed Sep 9, 2024
1 parent f869c7e commit 6655611
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions loadtest/control/simulcontroller/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,14 +1393,6 @@ func (c *SimulController) initialJoinTeam(u user.User) control.UserActionRespons
return resp
}

team, err := c.user.Store().CurrentTeam()
if err != nil {
return control.UserActionResponse{Err: control.NewUserError(err)}
} else if team == nil {
// only join a team if we are not in one already.
return c.joinTeam(c.user)
}

if c.user.Store().FeatureFlags()["WebSocketEventScope"] {
// Setting the active thread to empty to allow the optimization to kick in early.
// We don't do this in the webapp to keep the code simple, but it's okay to do this in load-test
Expand All @@ -1410,6 +1402,14 @@ func (c *SimulController) initialJoinTeam(u user.User) control.UserActionRespons
}
}

team, err := c.user.Store().CurrentTeam()
if err != nil {
return control.UserActionResponse{Err: control.NewUserError(err)}
} else if team == nil {
// only join a team if we are not in one already.
return c.joinTeam(c.user)
}

return resp
}

Expand Down

0 comments on commit 6655611

Please sign in to comment.