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

Don't send unneeded Product fields to API #75

Closed
wants to merge 1 commit into from

Conversation

skazi0
Copy link
Contributor

@skazi0 skazi0 commented Oct 5, 2021

Product structure was split into two parts. BasicProduct with fields
needed to identify the product and Product which embeds BasicProduct
and adds more fields on top.
For API calls which only need the basic fields, BasicProduct part can be
used even if Product was passed.

@skazi0 skazi0 requested a review from djoreilly October 5, 2021 09:42
Copy link
Collaborator

@djoreilly djoreilly left a comment

Choose a reason for hiding this comment

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

So this is just as optimization, as the api server just ignores those fields. Are there cases when having the extra fields make the payload significantly larger?

Summary string `xml:"summary,attr" json:"-"`
IsBase bool `xml:"isbase,attr" json:"-"`
IsBase bool `xml:"isbase,attr" json:"base"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

was changing the json tag intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was but not for this PR :o)
removed.

@skazi0
Copy link
Contributor Author

skazi0 commented Oct 5, 2021

This is more to match our payloads to API spec and original client than to save bandwidth.
The problem is just for bool fields as the rest is handled by "omitempty" tag.
That's why I created a separate PR for this to have some decision on weather we want this or not.

@@ -75,7 +75,7 @@ func showProduct(productQuery Product) (Product, error) {
func upgradeProduct(product Product) (Service, error) {
// NOTE: this can add some extra attributes to json payload which
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this comment be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -130,7 +126,7 @@ func activateProduct(product Product, email string) (Service, error) {
func deactivateProduct(product Product) (Service, error) {
// NOTE: this can add some extra attributes to json payload which
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this comment be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -5,11 +5,17 @@ import (
"strings"
)

// Product represents an installed product or product information from API
type Product struct {
// BasicProduct represents basic information on product, mostly for API requests
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe this comment could also mention that BasicProduct is used instead of Product to avoid sending unneeded bool json or something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Product structure was split into two parts. BasicProduct with fields
needed to identify the product and Product which embeds BasicProduct
and adds more fields on top.
For API calls which only need the basic fields, BasicProduct part can be
used even if Product was passed.
Copy link
Collaborator

@djoreilly djoreilly left a comment

Choose a reason for hiding this comment

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

lgtm

@djoreilly
Copy link
Collaborator

We discussed this last week and decided the change is not necessary. Closing.

@djoreilly djoreilly closed this Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants