-
Notifications
You must be signed in to change notification settings - Fork 38
feat: add attributed based recommender client sdk #1213
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
Conversation
| serverAddress = "http://" + serverAddress | ||
| } | ||
| // Ensure serverAddress doesn't have trailing slash | ||
| serverAddress = strings.TrimSuffix(serverAddress, "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this not always localhost?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be http://localhost:<some port>, I prefer the port to be specified from argument instead of hardcoded.
8120e8a to
fac9f1e
Compare
|
|
||
| // attributeBasedVMSizeRecommenderClient implements the AttributeBasedVMSizeRecommenderClient interface | ||
| // for interacting with Azure Attribute-Based VM Size Recommender API. | ||
| type attributeBasedVMSizeRecommenderClient struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to make it public as a producer and NewAttributeBasedVMSizeRecommenderClient should return the concrete type.
| ) | ||
|
|
||
| // AttributeBasedVMSizeRecommenderClient is an interface for interacting with the Azure Attribute-Based VM Size Recommender API. | ||
| type AttributeBasedVMSizeRecommenderClient interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface should be defined in the consumer side.
And it may be better to define the interface where we use it and we can have a fake implementation there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a bunch of interfaces defined with the client library itself. I think the point is to provide a self-contained library so users can directly use it: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/dynamic/dynamicinformer/interface.go#L26
| httpClient *http.Client | ||
| } | ||
|
|
||
| // NewAttributeBasedVMSizeRecommenderClient creates a new attribute-based VM size recommender client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation is anti-pattern,
// Bad:
package producer
type Thinger interface { Thing() bool }
type defaultThinger struct{ ... }
func (t defaultThinger) Thing() bool { ... }
func NewThinger() Thinger { return defaultThinger{ ... } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More details could be found in https://google.github.io/styleguide/go/decisions#interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lot of similar style: an example: https://github.com/argoproj/argo-cd/blob/d8c72c2c8ecf6a16f05fcac405de8c0728f0359f/applicationset/services/pull_request/azure_devops.go#L42C1-L63C2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zhiying-lin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved to unblock the project progress.
The interface style is also mentioned in https://go.dev/wiki/CodeReviewComments#interfaces.
I'll leave the decision to you, as it's more like a style issue.
Description of your changes
This PR adds the proto and sdk for querying the AttributedBaseRecommendations API.
Tested in standalone env with custom client: fee0b52
And configured with env
CAPACITY_ENDPOINTas:and
Both worked:
Fixes #
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer