Skip to content

Commit

Permalink
Make Go runtime match list min/max size optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro committed Nov 11, 2019
1 parent fbe9d80 commit a9b8228
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Runtime create tournament calls always return any existing tournament after repeated calls with the same ID.
- Upgrade to Go 1.13.4 and Debian buster-slim for base docker images.
- Limit maximum number of concurrent leaderboard/tournament callback executions.
- Allow Go runtime match listing operations min/max count to be optional.

### Fixed
- Correctly handle errors when concurrently writing new storage objects.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/gorilla/mux v1.7.3
github.com/gorilla/websocket v1.4.1
github.com/grpc-ecosystem/grpc-gateway v1.11.1
github.com/heroiclabs/nakama-common v1.1.1
github.com/heroiclabs/nakama-common v1.2.0
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/jackc/pgx v3.5.0+incompatible
github.com/jmhodges/levigo v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/heroiclabs/nakama-common v1.1.1 h1:JieHwfRhsZoTAbqnTI5hYoGhl0X/VyynuZ/G1AKINCs=
github.com/heroiclabs/nakama-common v1.1.1/go.mod h1:e8eLcnHLZnElf9yvJqrLGTbvnxXQJRLVGebx/5zRXc4=
github.com/heroiclabs/nakama-common v1.2.0 h1:CWqLPLV8/cIPAAR75VemY7t9zvDv0kd7Xzw9M5YXqsI=
github.com/heroiclabs/nakama-common v1.2.0/go.mod h1:e8eLcnHLZnElf9yvJqrLGTbvnxXQJRLVGebx/5zRXc4=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
12 changes: 9 additions & 3 deletions server/runtime_go_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ func (n *RuntimeGoNakamaModule) MatchCreate(ctx context.Context, module string,
return n.matchRegistry.CreateMatch(ctx, n.logger, fn, module, params)
}

func (n *RuntimeGoNakamaModule) MatchList(ctx context.Context, limit int, authoritative bool, label string, minSize, maxSize int, query string) ([]*api.Match, error) {
func (n *RuntimeGoNakamaModule) MatchList(ctx context.Context, limit int, authoritative bool, label string, minSize, maxSize *int, query string) ([]*api.Match, error) {
authoritativeWrapper := &wrappers.BoolValue{Value: authoritative}
var labelWrapper *wrappers.StringValue
if label != "" {
Expand All @@ -855,8 +855,14 @@ func (n *RuntimeGoNakamaModule) MatchList(ctx context.Context, limit int, author
if query != "" {
queryWrapper = &wrappers.StringValue{Value: query}
}
minSizeWrapper := &wrappers.Int32Value{Value: int32(minSize)}
maxSizeWrapper := &wrappers.Int32Value{Value: int32(maxSize)}
var minSizeWrapper *wrappers.Int32Value
if minSize != nil {
minSizeWrapper = &wrappers.Int32Value{Value: int32(*minSize)}
}
var maxSizeWrapper *wrappers.Int32Value
if maxSize != nil {
maxSizeWrapper = &wrappers.Int32Value{Value: int32(*maxSize)}
}

return n.matchRegistry.ListMatches(ctx, limit, authoritativeWrapper, labelWrapper, minSizeWrapper, maxSizeWrapper, queryWrapper)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ github.com/grpc-ecosystem/grpc-gateway/internal
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options
github.com/grpc-ecosystem/grpc-gateway/runtime
github.com/grpc-ecosystem/grpc-gateway/utilities
# github.com/heroiclabs/nakama-common v1.1.1
# github.com/heroiclabs/nakama-common v1.2.0
github.com/heroiclabs/nakama-common/api
github.com/heroiclabs/nakama-common/rtapi
github.com/heroiclabs/nakama-common/runtime
Expand Down

0 comments on commit a9b8228

Please sign in to comment.