Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tips #1

Open
haakonnessjoen opened this issue Jul 13, 2024 · 0 comments
Open

Tips #1

haakonnessjoen opened this issue Jul 13, 2024 · 0 comments

Comments

@haakonnessjoen
Copy link

atomic.AddInt32(&leastConnServer.ActiveConns, 1)

Just a tip, since this is a common way to burn yourself later. If a function is called "getXXXX" it should only get things, not mutate any data. But you are updating a counter inside the get function.

If someone else reads your code, or you read your own code later, and see a function called "getLeastConnectionsBackend()" being used, you would expect it to just feetch som information for you. And you are unaware that calling it greatly alters the program flow.

Just a friendly tip :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant