Skip to content

Commit

Permalink
Modify NewSDK(): Hardcode localhost (#3676)
Browse files Browse the repository at this point in the history
* Modify NewSDK(): Hardcode localhost

* update newSDK comment
  • Loading branch information
Kalaiselvi84 authored Mar 4, 2024
1 parent 42b1a92 commit c5f85e5
Showing 1 changed file with 11 additions and 6 deletions.
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

0 comments on commit c5f85e5

Please sign in to comment.