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

Modify NewSDK(): Hardcode localhost #3676

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions sdks/go/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@ var Logger ErrorLog = func(msg string, err error) {
fmt.Fprintf(os.Stderr, "%s: %s\n", msg, err)
}

// NewSDK starts a new SDK instance, and connects to localhost
// on port "AGONES_SDK_GRPC_PORT" which by default is 9357.
// NewSDK starts a new SDK instance, defaulting to a connection at "localhost:9357"
// unless overridden by "AGONES_SDK_GRPC_HOST" and "AGONES_SDK_GRPC_PORT" environment variables.
// Blocks until connection and handshake are made.
// Times out after 30 seconds.
func NewSDK() (*SDK, error) {
p := os.Getenv("AGONES_SDK_GRPC_PORT")
if p == "" {
p = "9357"
host := os.Getenv("AGONES_SDK_GRPC_HOST")
if host == "" {
host = "localhost"
}
addr := fmt.Sprintf("localhost:%s", p)

port := os.Getenv("AGONES_SDK_GRPC_PORT")
if port == "" {
port = "9357"
}
addr := fmt.Sprintf("%s:%s", host, port)
s := &SDK{
ctx: context.Background(),
}
Expand Down
Loading