-
Notifications
You must be signed in to change notification settings - Fork 769
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
Version Endpoint #2009
Version Endpoint #2009
Conversation
}{ | ||
Revision: revision, | ||
Version: version, | ||
}) | ||
} |
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.
Updated the version endpoint to create a static response once at startup, mimicking the pattern used for the bidder info handler. Changed response structure to list the revision first to match PBS-Java. This is not a breaking change for the admin endpoint and we might as well make it match for the public debut.
@@ -310,6 +311,7 @@ func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *R | |||
r.POST("/cookie_sync", endpoints.NewCookieSyncEndpoint(syncersByBidder, cfg, gdprPerms, r.MetricsEngine, pbsAnalytics, activeBidders).Handle) | |||
r.GET("/status", endpoints.NewStatusEndpoint(cfg.StatusResponse)) | |||
r.GET("/", serveIndex) | |||
r.Handler("GET", "/version", endpoints.NewVersionEndpoint(version.Ver, version.Rev)) |
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 endpoint registration looks different because it's adapting to the http.Handle interface already in use by the admin endpoint. The r.GET
call is just syntactical sugar around this anyway.
endpoints/version.go
Outdated
} | ||
if revision == "" { | ||
revision = versionNotSet |
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.
Nitpick: This could be a bit confusing. Ideally we should assign revisionNotSet
and not versionNotSet
to revision
. Do you think renaming versionNotSet
to either notSet
or valueNotSet
could be more straightforward?
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.
Renamed for clarity. I cannot rename it notSet
or valueNotSet
because it's in the same package (naming scope) as other endpoints.
}) | ||
if err != nil { | ||
glog.Errorf("/version Critical error when trying to marshal versionModel: %v", err) | ||
w.WriteHeader(http.StatusInternalServerError) |
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 we are not using w.WriteHeader(http.StatusInternalServerError)
in the new version. Why are we not writing this error anymore?
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 moved the json marshal outside of the endpoint, so that it happens only once at application startup. If it fails, PBS will panic. Thus, it's no longer possible for the error to occur within the endpoint.
version: "1.2.3", | ||
revision: "d6cd1e2bd19e03a81132a23b2025920577f84e37", | ||
expected: `{"revision":"d6cd1e2bd19e03a81132a23b2025920577f84e37","version":"1.2.3"}`, | ||
}, |
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.
Can we include these additional two tests?
{
description: "Empty",
version: "1.2.3",
revision: "",
expected: `{"revision":"not-set","version":"1.2.3"}`,
},
{
description: "Populated",
version: "",
revision: "d6cd1e2bd19e03a81132a23b2025920577f84e37",
expected: `{"revision":"d6cd1e2bd19e03a81132a23b2025920577f84e37","version":"not-set"}`,
},
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.
Sure.
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.
LGTM
Implements #1172