Loading CHANGELOG.md +7 −0 Original line number Diff line number Diff line Loading @@ -4,7 +4,14 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] ### Added - New Go code runtime for custom functions and authoritative match handlers. - Lua runtime token generator function now returns a second value representing the token's expiry. - Add local cache for in-memory storage to the Lua runtime. ### Fixed - Correctly merge new friend records when importing from Facebook. - Log correct registered hook names at startup. ## [2.0.3] - 2018-08-10 ### Added Loading build/Dockerfile +20 −3 Original line number Diff line number Diff line # docker build . --rm --build-arg version=2.0.4 --build-arg commit=master -t heroiclabs/nakama:2.0.4 FROM golang:1.10-alpine3.7 as builder ARG commit RUN apk --no-cache add ca-certificates gcc musl-dev git WORKDIR /go/src/github.com/heroiclabs/ RUN git config --global advice.detachedHead false && \ git clone -q -n https://github.com/heroiclabs/nakama WORKDIR /go/src/github.com/heroiclabs/nakama RUN git checkout -q "$commit" && \ GOOS=linux GOARCH=amd64 go build && \ mkdir -p /go/build && \ mv nakama /go/build FROM alpine:3.7 MAINTAINER Heroic Labs <support@heroiclabs.com> Loading @@ -12,12 +30,11 @@ RUN mkdir -p /nakama/data/modules && \ apk --no-cache add ca-certificates curl iproute2 WORKDIR /nakama/ COPY ./nakama ./nakama COPY --from=builder "/go/build/nakama" /nakama/ EXPOSE 7349 7350 7351 # set entry point to nakama so that it can be invoked from the `docker run nakama` ENTRYPOINT ["./nakama"] # curl fails on non-200 HTTP status code HEALTHCHECK --interval=5m --timeout=3s \ CMD curl -f http://localhost:7350/ || exit 1 build/plugin.Dockerfile 0 → 100644 +14 −0 Original line number Diff line number Diff line # docker build . --file ./plugin.Dockerfile --build-arg src=sample_go_module FROM golang:1.10-alpine3.7 as builder ARG src WORKDIR /go/src/$src COPY $src /go/src/$src RUN apk --no-cache add ca-certificates gcc musl-dev git && \ go get -u github.com/heroiclabs/nakama && \ GOOS=linux go build -buildmode=plugin . && \ mkdir -p /go/build && \ mv "/go/src/$src/$src.so" /go/build/ flags/flags.go +4 −4 Original line number Diff line number Diff line Loading @@ -352,9 +352,9 @@ func (fm *FlagMaker) enumerateAndCreate(prefix string, value reflect.Value, usag } usageDesc := fm.getUsage(optName, stField) if len(usageDesc) == 0 { optName = optName } //if len(usageDesc) == 0 { // optName = optName //} fm.enumerateAndCreate(optName, field, usageDesc) } Loading Loading @@ -450,7 +450,7 @@ func (fm *FlagMaker) defineFlag(name string, value reflect.Value, usage string) fm.fs.DurationVar(v, name, value.Interface().(time.Duration), usage) default: // (TODO) if one type defines time.Duration, we'll create a int64 flag for it. // Find some acceptible way to deal with it. // Find some acceptable way to deal with it. vv := ptrValue.Convert(int64PtrType).Interface().(*int64) fm.fs.Int64Var(vv, name, value.Int(), usage) } Loading main.go +10 −16 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import ( "os" "os/signal" "runtime" "sync" "syscall" "time" Loading Loading @@ -95,40 +94,35 @@ func main() { // Access to social provider integrations. socialClient := social.NewClient(5 * time.Second) // Used to govern once-per-server-start executions in all Lua runtime instances, across both pooled and match VMs. once := &sync.Once{} // Start up server components. matchmaker := server.NewLocalMatchmaker(startupLogger, config.GetName()) sessionRegistry := server.NewSessionRegistry() tracker := server.StartLocalTracker(logger, sessionRegistry, jsonpbMarshaler, config.GetName()) router := server.NewLocalMessageRouter(sessionRegistry, tracker, jsonpbMarshaler) stdLibs, modules, err := server.LoadRuntimeModules(startupLogger, config) if err != nil { startupLogger.Fatal("Failed reading runtime modules", zap.Error(err)) } leaderboardCache := server.NewLocalLeaderboardCache(logger, startupLogger, db) matchRegistry := server.NewLocalMatchRegistry(logger, db, config, socialClient, leaderboardCache, sessionRegistry, tracker, router, stdLibs, once, config.GetName()) matchRegistry := server.NewLocalMatchRegistry(logger, config, tracker, config.GetName()) tracker.SetMatchJoinListener(matchRegistry.Join) tracker.SetMatchLeaveListener(matchRegistry.Leave) // Separate module evaluation/validation from module loading. // We need the match registry to be available to wire all functions exposed to the runtime, which in turn needs the modules at least cached first. regCallbacks, err := server.ValidateRuntimeModules(logger, startupLogger, db, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router, stdLibs, modules, once) runtime, err := server.NewRuntime(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router) if err != nil { startupLogger.Fatal("Failed initializing runtime modules", zap.Error(err)) } runtimePool := server.NewRuntimePool(logger, startupLogger, db, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router, stdLibs, modules, regCallbacks, once) pipeline := server.NewPipeline(config, db, jsonpbMarshaler, jsonpbUnmarshaler, sessionRegistry, matchRegistry, matchmaker, tracker, router, runtimePool) pipeline := server.NewPipeline(logger, config, db, jsonpbMarshaler, jsonpbUnmarshaler, sessionRegistry, matchRegistry, matchmaker, tracker, router, runtime) metrics := server.NewMetrics(logger, startupLogger, config) consoleServer := server.StartConsoleServer(logger, startupLogger, config, db) apiServer := server.StartApiServer(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, matchmaker, tracker, router, pipeline, runtimePool) apiServer := server.StartApiServer(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, matchmaker, tracker, router, pipeline, runtime) gaenabled := len(os.Getenv("NAKAMA_TELEMETRY")) < 1 cookie := newOrLoadCookie(config) gacode := "UA-89792135-1" var telemetryClient *http.Client if gaenabled { runTelemetry(http.DefaultClient, gacode, cookie) telemetryClient = &http.Client{ Timeout: 1500 * time.Millisecond, } runTelemetry(telemetryClient, gacode, cookie) } // Respect OS stop signals. Loading @@ -150,7 +144,7 @@ func main() { sessionRegistry.Stop() if gaenabled { ga.SendSessionStop(http.DefaultClient, gacode, cookie) ga.SendSessionStop(telemetryClient, gacode, cookie) } os.Exit(0) Loading Loading
CHANGELOG.md +7 −0 Original line number Diff line number Diff line Loading @@ -4,7 +4,14 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] ### Added - New Go code runtime for custom functions and authoritative match handlers. - Lua runtime token generator function now returns a second value representing the token's expiry. - Add local cache for in-memory storage to the Lua runtime. ### Fixed - Correctly merge new friend records when importing from Facebook. - Log correct registered hook names at startup. ## [2.0.3] - 2018-08-10 ### Added Loading
build/Dockerfile +20 −3 Original line number Diff line number Diff line # docker build . --rm --build-arg version=2.0.4 --build-arg commit=master -t heroiclabs/nakama:2.0.4 FROM golang:1.10-alpine3.7 as builder ARG commit RUN apk --no-cache add ca-certificates gcc musl-dev git WORKDIR /go/src/github.com/heroiclabs/ RUN git config --global advice.detachedHead false && \ git clone -q -n https://github.com/heroiclabs/nakama WORKDIR /go/src/github.com/heroiclabs/nakama RUN git checkout -q "$commit" && \ GOOS=linux GOARCH=amd64 go build && \ mkdir -p /go/build && \ mv nakama /go/build FROM alpine:3.7 MAINTAINER Heroic Labs <support@heroiclabs.com> Loading @@ -12,12 +30,11 @@ RUN mkdir -p /nakama/data/modules && \ apk --no-cache add ca-certificates curl iproute2 WORKDIR /nakama/ COPY ./nakama ./nakama COPY --from=builder "/go/build/nakama" /nakama/ EXPOSE 7349 7350 7351 # set entry point to nakama so that it can be invoked from the `docker run nakama` ENTRYPOINT ["./nakama"] # curl fails on non-200 HTTP status code HEALTHCHECK --interval=5m --timeout=3s \ CMD curl -f http://localhost:7350/ || exit 1
build/plugin.Dockerfile 0 → 100644 +14 −0 Original line number Diff line number Diff line # docker build . --file ./plugin.Dockerfile --build-arg src=sample_go_module FROM golang:1.10-alpine3.7 as builder ARG src WORKDIR /go/src/$src COPY $src /go/src/$src RUN apk --no-cache add ca-certificates gcc musl-dev git && \ go get -u github.com/heroiclabs/nakama && \ GOOS=linux go build -buildmode=plugin . && \ mkdir -p /go/build && \ mv "/go/src/$src/$src.so" /go/build/
flags/flags.go +4 −4 Original line number Diff line number Diff line Loading @@ -352,9 +352,9 @@ func (fm *FlagMaker) enumerateAndCreate(prefix string, value reflect.Value, usag } usageDesc := fm.getUsage(optName, stField) if len(usageDesc) == 0 { optName = optName } //if len(usageDesc) == 0 { // optName = optName //} fm.enumerateAndCreate(optName, field, usageDesc) } Loading Loading @@ -450,7 +450,7 @@ func (fm *FlagMaker) defineFlag(name string, value reflect.Value, usage string) fm.fs.DurationVar(v, name, value.Interface().(time.Duration), usage) default: // (TODO) if one type defines time.Duration, we'll create a int64 flag for it. // Find some acceptible way to deal with it. // Find some acceptable way to deal with it. vv := ptrValue.Convert(int64PtrType).Interface().(*int64) fm.fs.Int64Var(vv, name, value.Int(), usage) } Loading
main.go +10 −16 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import ( "os" "os/signal" "runtime" "sync" "syscall" "time" Loading Loading @@ -95,40 +94,35 @@ func main() { // Access to social provider integrations. socialClient := social.NewClient(5 * time.Second) // Used to govern once-per-server-start executions in all Lua runtime instances, across both pooled and match VMs. once := &sync.Once{} // Start up server components. matchmaker := server.NewLocalMatchmaker(startupLogger, config.GetName()) sessionRegistry := server.NewSessionRegistry() tracker := server.StartLocalTracker(logger, sessionRegistry, jsonpbMarshaler, config.GetName()) router := server.NewLocalMessageRouter(sessionRegistry, tracker, jsonpbMarshaler) stdLibs, modules, err := server.LoadRuntimeModules(startupLogger, config) if err != nil { startupLogger.Fatal("Failed reading runtime modules", zap.Error(err)) } leaderboardCache := server.NewLocalLeaderboardCache(logger, startupLogger, db) matchRegistry := server.NewLocalMatchRegistry(logger, db, config, socialClient, leaderboardCache, sessionRegistry, tracker, router, stdLibs, once, config.GetName()) matchRegistry := server.NewLocalMatchRegistry(logger, config, tracker, config.GetName()) tracker.SetMatchJoinListener(matchRegistry.Join) tracker.SetMatchLeaveListener(matchRegistry.Leave) // Separate module evaluation/validation from module loading. // We need the match registry to be available to wire all functions exposed to the runtime, which in turn needs the modules at least cached first. regCallbacks, err := server.ValidateRuntimeModules(logger, startupLogger, db, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router, stdLibs, modules, once) runtime, err := server.NewRuntime(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router) if err != nil { startupLogger.Fatal("Failed initializing runtime modules", zap.Error(err)) } runtimePool := server.NewRuntimePool(logger, startupLogger, db, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, tracker, router, stdLibs, modules, regCallbacks, once) pipeline := server.NewPipeline(config, db, jsonpbMarshaler, jsonpbUnmarshaler, sessionRegistry, matchRegistry, matchmaker, tracker, router, runtimePool) pipeline := server.NewPipeline(logger, config, db, jsonpbMarshaler, jsonpbUnmarshaler, sessionRegistry, matchRegistry, matchmaker, tracker, router, runtime) metrics := server.NewMetrics(logger, startupLogger, config) consoleServer := server.StartConsoleServer(logger, startupLogger, config, db) apiServer := server.StartApiServer(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, matchmaker, tracker, router, pipeline, runtimePool) apiServer := server.StartApiServer(logger, startupLogger, db, jsonpbMarshaler, jsonpbUnmarshaler, config, socialClient, leaderboardCache, sessionRegistry, matchRegistry, matchmaker, tracker, router, pipeline, runtime) gaenabled := len(os.Getenv("NAKAMA_TELEMETRY")) < 1 cookie := newOrLoadCookie(config) gacode := "UA-89792135-1" var telemetryClient *http.Client if gaenabled { runTelemetry(http.DefaultClient, gacode, cookie) telemetryClient = &http.Client{ Timeout: 1500 * time.Millisecond, } runTelemetry(telemetryClient, gacode, cookie) } // Respect OS stop signals. Loading @@ -150,7 +144,7 @@ func main() { sessionRegistry.Stop() if gaenabled { ga.SendSessionStop(http.DefaultClient, gacode, cookie) ga.SendSessionStop(telemetryClient, gacode, cookie) } os.Exit(0) Loading