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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement instance info endpoint (JSON, YAML, TXT) #685
Conversation
da71ab4
to
cb310e8
Compare
cb310e8
to
b18a120
Compare
Accidental approval -- comments still stand.
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.
(leaving a comment to convince GitHub that I'm requesting changes, which I am)
I've removed the hard-coded colors from the Otherwise looks great to me! I think Daniel had a couple more comments but I'm looking forward to this being merged. |
https://685.fly.dev/
Fixes #624
I added a feature to the
time
crate to allow for local timezone loading. I also addedserde_yaml
so we could return it in YAML form, as well as JSON and regular text; as well asbuild_html
in order to more easily construct an HTML table. These are quite small dependencies. Here's what they look like:HTML (default with /instance-info)
JSON
YAML
TXT
The
build.rs
is required and standard practice to set a variable - AFAIK it's the easiest way to embed the latest commit hash.Within
instance_info.rs
, I made some choices - theInstanceInfo
struct will be held in a Lazy. Currently nothing in the struct should change so it's okay to cache it. However, from #624:If we add either of these, it will change on the fly, so we need to revisit the use of a
Lazy<InstanceInfo>
.Within the
instance_info
function, I choosehtml
as the default.In
main.rs
, I forced evaluation of the two relevant statics (config and instance info) to ensure deploy timestamp is accurate, and to avoid paying the penalty of parsing the config at the first request.In conclusion, this PR will allow us to implement a system where we can easily check if an instance is actually online and lets us measure versions across the instance ecosystem. If we add metrics like average Reddit latency or number of responses served, we can more accurately predict the performance of certain servers and bias a redirect server (going to work on this in the coming days 馃槈) towards those.
I also added a link to the instance info page into
base.html
:The groundwork is also laid for a banner #347 - it's been included in the parsing code and is shown on the instance page. We need to discuss whether we want to display it on regular pages (footer? header? where? etc) or just on the info page.
I also added a "LIBREDDIT_DEFAULT_HIDE_AWARDS" option for a default - in case a server operator wants to hide it by default (goes with #678).