Async::ServiceSourceAsyncServiceFormatting

module Formatting

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.

Signature

deprecated

Use String::Format directly.

Definitions

def format_count(value, units = String::Format::UNITS)

Format a count into a human-readable string.

Signature

parameter value Numeric

The count to format.

parameter units Array

The units to use for formatting (default: String::Format::UNITS).

returns String

A formatted string representing the count.

Implementation

def format_count(value, units = String::Format::UNITS)
	String::Format.count(value, units)
end

def format_ratio(current, total)

Format a ratio as "current/total" with human-readable counts.

Signature

parameter current Numeric

The current value.

parameter total Numeric

The total value.

returns String

A formatted ratio string.

Implementation

def format_ratio(current, total)
	String::Format.ratio(current, total)
end

def format_load(load)

Format a load value as a decimal with specified precision.

Signature

parameter load Numeric

The load value (typically 0.0 to 1.0+).

returns String

A formatted load string.

Implementation

def format_load(load)
	String::Format.decimal(load)
end

def format_statistics(**pairs)

Format multiple statistics into a compact string.

Signature

parameter pairs Hash

Hash of statistic names to values or [current, total] arrays.

returns String

A formatted statistics string.

Implementation

def format_statistics(**pairs)
	String::Format.statistics(pairs)
end