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

Refactor simple-game-server #3813

Open
markmandel opened this issue May 8, 2024 · 0 comments · May be fixed by #3817
Open

Refactor simple-game-server #3813

markmandel opened this issue May 8, 2024 · 0 comments · May be fixed by #3817
Assignees
Labels
area/examples Examples. Usually found in the `examples` directory kind/cleanup Refactoring code, fixing up documentation, etc

Comments

@markmandel
Copy link
Member

https://github.com/googleforgames/agones/blob/main/examples/simple-game-server/main.go is getting really large, and a little unweildy!

Let's take some time to refactor it it into something that's a bit more manageable.

Some suggestions include:

  • Use a map of commands rather than a giant switch statement
  • Split into multiple files (where it makes sense)
  • A lot of the SDK calls, such as setAnnotation(...) have very similar function wrappers - can we generalise this in some way?

func setAnnotation(s *sdk.SDK, key, value string) {
log.Printf("Setting annotation %v=%v", key, value)
err := s.SetAnnotation(key, value)
if err != nil {
log.Fatalf("could not set annotation: %v", err)
}
}

...and anything else that jumps out!

@markmandel markmandel added kind/cleanup Refactoring code, fixing up documentation, etc area/examples Examples. Usually found in the `examples` directory labels May 8, 2024
@ashutosji ashutosji linked a pull request May 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/examples Examples. Usually found in the `examples` directory kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants