You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/async/service/formatting.rb
+11-38Lines changed: 11 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -3,40 +3,24 @@
3
3
# Released under the MIT License.
4
4
# Copyright, 2025, by Samuel Williams.
5
5
6
+
require"string/format"
7
+
6
8
moduleAsync
7
9
moduleService
8
10
# Formatting utilities for service titles.
9
11
#
10
12
# 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.
11
13
#
12
14
# It is expected you will include these into your service class and use them to update the `instance.name` in the health check.
15
+
#
16
+
# @deprecated Use {String::Format} directly.
13
17
moduleFormatting
14
-
UNITS=[nil,"K","M","B","T","P","E","Z","Y"]
15
-
16
18
# Format a count into a human-readable string.
17
19
# @parameter value [Numeric] The count to format.
18
-
# @parameter units [Array] The units to use for formatting (default: UNITS).
20
+
# @parameter units [Array] The units to use for formatting (default: String::Format::UNITS).
19
21
# @returns [String] A formatted string representing the count.
20
-
defformat_count(value,units=UNITS)
21
-
value=value
22
-
index=0
23
-
limit=units.size - 1
24
-
25
-
# Handle negative numbers by working with absolute value:
0 commit comments