-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDKServer Player Tracking implementation #1507
SDKServer Player Tracking implementation #1507
Conversation
Build Succeeded 👏 Build Id: 059fb6fa-d728-4f14-b1c7-903a3dc95ada The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
pkg/sdkserver/sdkserver_test.go
Outdated
assert.False(t, ok.Bool, "no player connected yet") | ||
|
||
// sdk value should always be correct, even if we send more than one update per second. | ||
for i := 0; i < 3; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it would be easier to understand why 3
(if I got it right):
for i := 0; i < 3; i++ { | |
for i := 0; i < capacity; i++ { |
pkg/sdkserver/sdkserver_test.go
Outdated
} | ||
count, err = sc.GetPlayerCount(context.Background(), e) | ||
assert.NoError(t, err) | ||
assert.Equal(t, int64(3), count.Count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above?
assert.Equal(t, int64(3), count.Count) | |
assert.Equal(t, capacity, count.Count) |
pkg/sdkserver/sdkserver_test.go
Outdated
// on an update, confirm that the update hits the K8s api, only once | ||
select { | ||
case value := <-updated: | ||
assert.Equal(t, int64(3), value.Count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here also
assert.Equal(t, int64(3), value.Count) | |
assert.Equal(t, capacity, value.Count) |
pkg/sdkserver/sdkserver_test.go
Outdated
|
||
// sdk value should always be correct, even if we send more than one update per second. | ||
// let's leave one player behind | ||
for i := 0; i < 2; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i := 0; i < 2; i++ { | |
for i := 0; i < capacity-1; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I like that. Nice.
pkg/sdkserver/sdkserver_test.go
Outdated
id := &alpha.PlayerID{PlayerID: token} | ||
ok, err := sc.PlayerDisconnect(context.Background(), id) | ||
assert.NoError(t, err) | ||
assert.True(t, ok.Bool, "Player "+token+" should be disconnected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bit easier to read
assert.True(t, ok.Bool, "Player "+token+" should be disconnected") | |
assert.True(t, ok.Bool, "Player %s should be disconnected", token) |
pkg/sdkserver/sdkserver.go
Outdated
@@ -547,35 +555,108 @@ func (s *SDKServer) stopReserveTimer() { | |||
// [Stage:Alpha] | |||
// [FeatureFlag:PlayerTracking] | |||
func (s *SDKServer) PlayerConnect(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error) { | |||
panic("implement me") | |||
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | |||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be something like:
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | |
return nil, errors.New(fmt.Sprintf("feature gate '%s' is not enabled", runtime.FeaturePlayerTracking)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've currently got this code all through localsdk.go as well. Should I change both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, this should errors.Errorf(...)
- which is much better. I'll make the change here, and come back around to localsdk.go in a later PR.
pkg/sdkserver/sdkserver.go
Outdated
} | ||
|
||
if int64(len(s.gsConnectedPlayers)) >= s.gsPlayerCapacity { | ||
return &alpha.Bool{}, errors.New("Players are already at capacity") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case for errors
https://github.com/golang/go/wiki/CodeReviewComments#error-strings
return &alpha.Bool{}, errors.New("Players are already at capacity") | |
return &alpha.Bool{}, errors.New("players are already at capacity") |
pkg/sdkserver/sdkserver.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
s.logger.WithField("PlayerId", id).Debug("Player Disconnected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if previous version parse pointers in a correct way.
s.logger.WithField("PlayerId", id).Debug("Player Disconnected") | |
s.logger.WithField("PlayerId", id.PlayerID).Debug("Player Disconnected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, excellent point.
pkg/sdkserver/sdkserver.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
s.logger.WithField("playerIDs", s.gsConnectedPlayers).Debug("updating connected players") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might go also after lock.
s.logger.WithField("playerIDs", s.gsConnectedPlayers).Debug("updating connected players") | |
s.gsUpdateMutex.RLock() | |
s.logger.WithField("playerIDs", s.gsConnectedPlayers).Debug("updating connected players") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall is great. Left some points - potential issues.
35c17f9
to
79dc130
Compare
Build Succeeded 👏 Build Id: cbd43784-331a-42c9-8f63-96ab7698143b The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
pkg/sdkserver/sdkserver.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.Errorf("%s not enabled", runtime.FeaturePlayerTracking) | ||
} | ||
s.logger.WithField("PlayerId", id).Debug("Player Connected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Mark, one more
s.logger.WithField("PlayerId", id).Debug("Player Connected") | |
s.logger.WithField("PlayerId", id.PlayerID).Debug("Player Connected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Applying now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for applying all the comments. Please apply one more log improvement (nit).
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aLekSer, markmandel The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Implementation of the SDK gRPC Server, with accompanying unit tests. Work on googleforgames#1033
Cleanup the remainder `errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")` to be being `errors.Errorf("%s not enabled", runtime.FeaturePlayerTracking)`, which is much nicer. Work on googleforgames#1507
Includes implementations and unit tests for PlayerConnect, PlayerDisconnect, GetPlayerCount, IsPlayerConnected and GetConnectedPlayers. Conformance tests will come in the next PR. Work on googleforgames#1507
Cleanup the remainder `errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")` to be being `errors.Errorf("%s not enabled", runtime.FeaturePlayerTracking)`, which is much nicer. Work on #1507
Includes implementations and unit tests for PlayerConnect, PlayerDisconnect, GetPlayerCount, IsPlayerConnected and GetConnectedPlayers. Conformance tests will come in the next PR. Work on googleforgames#1507
Includes implementations and unit tests for PlayerConnect, PlayerDisconnect, GetPlayerCount, IsPlayerConnected and GetConnectedPlayers. Conformance tests will come in the next PR. Work on #1507 Co-authored-by: Alexander Apalikov <alexander.apalikov@globant.com>
Conformance tests for the Go SDK. Work on googleforgames#1507
Conformance tests for the Go SDK. Work on googleforgames#1507
Conformance tests for the Go SDK. Work on googleforgames#1507
Conformance tests for the Go SDK. Work on googleforgames#1507
Conformance tests for the Go SDK. Work on #1507
Conformance tests for the REST API. Work on googleforgames#1507
Conformance tests for the REST API. Work on googleforgames#1507
Conformance tests for the REST API. Work on googleforgames#1507
Conformance tests for the REST API. Work on #1507
Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on googleforgames#1507
Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on googleforgames#1507
Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on googleforgames#1507
* E2E Tests for GameServer Player Tracking Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on #1507
Implementation of the SDK gRPC Server, with accompanying unit tests. Work on googleforgames#1033
Cleanup the remainder `errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")` to be being `errors.Errorf("%s not enabled", runtime.FeaturePlayerTracking)`, which is much nicer. Work on googleforgames#1507
) Includes implementations and unit tests for PlayerConnect, PlayerDisconnect, GetPlayerCount, IsPlayerConnected and GetConnectedPlayers. Conformance tests will come in the next PR. Work on googleforgames#1507 Co-authored-by: Alexander Apalikov <alexander.apalikov@globant.com>
Conformance tests for the Go SDK. Work on googleforgames#1507
Conformance tests for the REST API. Work on googleforgames#1507
* E2E Tests for GameServer Player Tracking Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on googleforgames#1507
* E2E Tests for GameServer Player Tracking Updated the udp-simple example to accept various player tracking commands, and also implemented e2e tests to test it working on a singular GameServer instance. Work on googleforgames#1507
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Implementation of the SDK gRPC Server, with accompanying unit tests.
Which issue(s) this PR fixes:
Work on #1033
Special notes for your reviewer:
None.