Module: Async::Service::Formatting Deprecated
- Defined in:
- lib/async/service/formatting.rb
Overview
Use String::Format directly.
Formatting utilities for service titles.
Services need meaningful process/thread names for monitoring and debugging. This module provides consistent formatting for common service metrics like connection counts, request ratios, and load values in process titles.
It is expected you will include these into your service class and use them to update the ‘instance.name` in the health check.
Class Method Summary collapse
-
.format_count(value, units = String::Format::UNITS) ⇒ Object
Format a count into a human-readable string.
-
.format_load(load) ⇒ Object
Format a load value as a decimal with specified precision.
-
.format_ratio(current, total) ⇒ Object
Format a ratio as “current/total” with human-readable counts.
-
.format_statistics(**pairs) ⇒ Object
Format multiple statistics into a compact string.
Class Method Details
.format_count(value, units = String::Format::UNITS) ⇒ Object
Format a count into a human-readable string.
22 23 24 |
# File 'lib/async/service/formatting.rb', line 22 def format_count(value, units = String::Format::UNITS) String::Format.count(value, units) end |
.format_load(load) ⇒ Object
Format a load value as a decimal with specified precision.
41 42 43 |
# File 'lib/async/service/formatting.rb', line 41 def format_load(load) String::Format.decimal(load) end |
.format_ratio(current, total) ⇒ Object
Format a ratio as “current/total” with human-readable counts.
32 33 34 |
# File 'lib/async/service/formatting.rb', line 32 def format_ratio(current, total) String::Format.ratio(current, total) end |
.format_statistics(**pairs) ⇒ Object
Format multiple statistics into a compact string.
50 51 52 |
# File 'lib/async/service/formatting.rb', line 50 def format_statistics(**pairs) String::Format.statistics(pairs) end |