googleforgames / agones

Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes

Home Page:https://agones.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor simple-game-server

markmandel opened this issue · comments

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!