Skip to content
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

Experimental Go GSDK #103

Merged
merged 5 commits into from
Nov 13, 2021
Merged

Experimental Go GSDK #103

merged 5 commits into from
Nov 13, 2021

Conversation

dgkanatsios
Copy link
Contributor

This PR includes the Go GSDK. Highly experimental, not to be used in production. Supported only on this GitHub repo by opening an issue.

@dgkanatsios dgkanatsios self-assigned this Nov 5, 2021
@dgkanatsios dgkanatsios changed the title Go GSDK Experimental Go GSDK Nov 5, 2021
Copy link

@khaines khaines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start @dgkanatsios! Most of my comments are nits or typos, but there are a few we can discuss on teams if you want since I might not have all the context for the choices made.

experimental/go/README.md Outdated Show resolved Hide resolved
experimental/go/internalgsdk.go Outdated Show resolved Hide resolved
experimental/go/gsdk.go Outdated Show resolved Hide resolved

if hr.NextScheduledMaintenanceUtc != "" {
nextScheduledMaintenanceUtc, _ := time.Parse(time.RFC3339, hr.NextScheduledMaintenanceUtc)
if i.cachedScheduledMaintenanceUtc.IsZero() || nextScheduledMaintenanceUtc.After(i.cachedScheduledMaintenanceUtc) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be 100% certain you are using it as a UTC value, since the string is from a web call, you should use the .UTC() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean on the hr.NextScheduledMaintenanceUtc value?

Copy link

@khaines khaines Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextScheduledMaintenanceUtc, in this case that one specifically.

{
if i.currentGameState != GameStateTerminating {
i.currentGameState = GameStateTerminating
go func() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this signaling of a heartbeat is a duplicate block from line 187. Please consider making this its own method.

experimental/go/logger.go Show resolved Hide resolved
experimental/go/gsdk.go Outdated Show resolved Hide resolved
experimental/go/gsdk.go Outdated Show resolved Hide resolved
experimental/go/gsdk.go Show resolved Hide resolved
experimental/go/gsdk_test.go Show resolved Hide resolved
experimental/go/README.md Outdated Show resolved Hide resolved
if i.configuration == nil {
i.configuration, err = i.getConfiguration()
if err != nil {
log.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious. Will this work as expected given that this is called before the initializeLogger method on line 80?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I had to do this since we rely on the configuration values to initialize the logger. I'm pretty sure (TM) this will work and panic the program, it will just not have the configuration values (which we have failed to retrieve anyway)

experimental/go/internalgsdk.go Show resolved Hide resolved
postBody, _ := json.Marshal(hrr)
requestBody := bytes.NewBuffer(postBody)

resp, err := http.Post(heartbeatEndpoint, "application/json", requestBody)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that in the Java GSDK we have some retry logic wrapped around this call.

Retryer<SessionHostHeartbeatInfo> retryer = RetryerBuilder.<SessionHostHeartbeatInfo>newBuilder()
Should we do that here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I followed up the C# GSDK during the Go GSDK creation, it doesn't seem to exist there. Let's keep it simple for this first version, we can add it later.

logWarn(fmt.Sprintf("Error parsing heartbeat response %s", err))
}

i.updateStateFromHeartbeat(&hbr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the Java GSDK here (

if (currentState == SessionHostStatus.Terminating)
) it looks like we check to see if we're in the Terminating state before we process the incoming heartbeat. If we are in that state then we immediately send a heartbeat to the Agent saying that we're in the Terminated state and then halt further processing. I haven't read this entire PR yet, but I don't see anything in this GSDK that sends the Terminated heartbeat to the Agent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, that's interesting - I don't think we send the Terminated ever on the C# GSDK. We'll need to check this and see what's going on

@dgkanatsios dgkanatsios merged commit 6f13739 into master Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants