Hey guys, I have been following the following tutorials in order to try to improve my server setup using Go with Nakama:
https://www.youtube.com/watch?v=VbVEMsmJ3ds - Bucketed leaderboards using Nakama Server Runtime
https://www.youtube.com/watch?v=Ru3RZ6LkJEk - Nakama Server Runtime Code Project Setup Using Go
All of this was with the intention of creating a leaderboard for my Unity game. I will preface this by sayign that this is my first time writing anything in Go so it is very difficult for me to debug in this.
Following the first tutorial, there was no healthcheck running and no added options in the API explorer.
I decided to push on and follow the leaderboard tutorial on the video. I believe that I have followed everything correctly, however after running “docker compose up” in my windows command terminal in the correct directory, and looking at the Nakama console, there are no buckets created and there are no leaderboards.
I am not sure if I need to add anything extra to the likes of my docker-compose file or any other files. The functions in my main.go file look as follows:
func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
logger.Info("Go module loaded.")
leaderboardId := "bucketed_weekly"
createLeaderboard(leaderboardId, "Bucketed Weekly #1", ctx, logger, nk)
if err := initializer.RegisterRpc("get_bucket_records", modules.RpcGetBucketRecordsFn([]string{leaderboardId}, 20, false)); err != nil {
return err
}
if err := initializer.RegisterRpc("get_bucket_records_force_regenerate", modules.RpcGetBucketRecordsFn([]string{leaderboardId}, 20, true)); err != nil {
return err
}
return nil
}
func createLeaderboard(id string, title string, ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule) error {
logger.Info("Creating Leaderboard with ID %q and Title %q", id, title)
err := nk.LeaderboardCreate(ctx, id, false, "desc", "incr", "0 0 * * 0", nil)
if err != nil {
logger.Error(err.Error())
return err
}
logger.Info("Leaderboard %q created successfully", id)
return nil
}
If you need me to share my full repo, other files, or anything else I’d be more than happy to. Any advice would be fantastic! Thanks in advance!