thousandeyes / thousandeyes-sdk-go

Thousandeyes golang API wrapper
Apache License 2.0
12 stars 23 forks source link

refactor!: use pointers in struct fields #90

Closed raul-te closed 2 years ago

raul-te commented 2 years ago

This pull request is the first of a set of refactories with breaking changes. The objective is mitigate a class of bugs (for example) where the JSON marshaling fails to distinguish between unset fields and those set to a zero-value. One solution is to use pointers for struct fields. This concept isn't novel, I've taken it from the go-github wrapper.

Additionally, I'm including two other changes:

All tests are passing after these changes:

$ go test
2022/05/20 16:12:46 [INFO] 100 of 240 requests / min remain.  Sleeping 750ms to prevent rate limiting.
2022/05/20 16:12:46 [INFO] 100 of 240 requests / min remain.  Sleeping 2s to prevent rate limiting.
2022/05/20 16:12:46 [INFO] 100 of 240 requests / min remain.  Sleeping 2s to prevent rate limiting.
2022/05/20 16:12:46 [INFO] 100 of 240 requests / min remain.  Sleeping 250ms to prevent rate limiting.
2022/05/20 16:12:46 [INFO] Rate Limited: Sleeping 31s before resubmitting
2022/05/20 16:12:46 [INFO] Rate Limited: Sleeping 31s before resubmitting
2022/05/20 16:12:46 [INFO] 240 of 240 requests / min remain.  Sleeping 250ms to prevent rate limiting.
2022/05/20 16:12:46 [INFO] Rate Limited: Sleeping 1m0s before resubmitting
PASS
ok      github.com/thousandeyes/go-thousandeyes 0.100s
raul-te commented 2 years ago

I'll merge and apply the recommendations on a new pull request. This one is already too bloated.