The runtime framework for Nakama server.
This codebase defines the runtime API and protocol interface used by Nakama.
The code is broken up into packages for different parts of the runtime framework:
api
- The request/response messages used with GRPC and in some of the realtime API.rtapi
- The realtime messages sent and received over a socket connection.runtime
- The Go types and functional interface used by Nakama plugins to execute native logic. See the Nakama server documentation for more info.
The codebase uses Protocol Buffers. The protoc toolchain is used to generate source files which are committed to the repository to simplify builds for contributors.
To build the codebase and generate all sources use these steps.
-
Install the Go toolchain and protoc toolchain.
-
Intall the protoc-gen-go plugin to generate Go code.
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
-
Use the Go generate command to generate all Go stubs.
env PATH="$HOME/go/bin:$PATH" go generate -x ./...
These steps have been tested with the Go 1.14 toolchain. Earlier Go toolchain versions may work though YMMV.
To use the Go language with your Nakama server project you compile your code as a shared object. Use these basic steps to set up the Go project and consult the documentation for more information.
-
Install the Go toolchain.
NOTE: You must use the exact same version of the Go toolchain as the specific release the server was built with. Run the server with "--logger.level DEBUG" to see the version of the Go runtime used.
-
Create a Go project.
go mod init "myproject/server"
-
Add this package as a dependency to the project and vendor it.
go get -u "github.com/heroiclabs/nakama-common/runtime" go mod vendor
-
Write your Go code and compile it as a Go plugin
go build -buildmode=plugin -trimpath
Make sure that the package.json
version is in tandem with the go package releases.
This project is licensed under the Apache-2 License.