July 2023
Intermediate to advanced
670 pages
17h 13m
English
So far, you’ve learned how to create a reference that has the lifetime of some single IO action, but in some cases it would be convenient to have a reference that is available to your entire program, and for the lifetime of the application. Although global mutable data is often cast as inadvisable at best, and an antipattern at worst, there are situations where module-level global variables can be quite useful. One of these situations is when dealing with global concerns like logging or metrics. In this section, we’ll look at how to build a minimal metrics system that you can use to instrument a program.
Let’s start by defining a new record, AppMetrics, that we’ll use to hold all of our different ...
Read now
Unlock full access