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

docs(client): make example in README compile #604

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 5 additions & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ import (
"time"

toxiproxy "github.com/Shopify/toxiproxy/v2/client"
"github.com/garyburd/redigo/redis"
"github.com/gomodule/redigo/redis"
)

var toxiClient *toxiproxy.Client
Expand All @@ -114,6 +114,10 @@ func init() {
if err != nil {
panic(err)
}
proxies, err = toxiClient.Proxies()
if err != nil {
panic(err)
}
Comment on lines +117 to +120
Copy link
Member

Choose a reason for hiding this comment

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

This addition seems incorrect as proxies is assigned on line 108 as a result of the toxiClient.Populate call.

If this is meant as another example, similar to the example on line 122, I would be okay with this remaining but the indentation should be fixed, it should be commented out, and a comment added explaining what it does if its uncommented.

Copy link
Author

Choose a reason for hiding this comment

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

Populate returns an array, not a map: https://pkg.go.dev/github.com/shopify/toxiproxy/client#Client.Populate
Which is why this program was not compiling. I just looked through the API quickly and found Proxies() which returns a map instead. I'm assuming the API changed at some point. Not sure if this is correct semantically though... spent like 5 mins on this last night.

// Alternatively, create the proxies manually with
// toxiClient.CreateProxy("redis", "localhost:26379", "localhost:6379")
}
Expand Down
Loading