Parse-async-logger-config-text
Parse raw JSON text into AsyncLoggerConfig. This helper is the text-entry counterpart to AsyncLoggerConfig::new(...) when async queue and flush policy should be configured from serialized data.
Interface
pub fn parse_async_logger_config_text(input : String) -> AsyncLoggerConfig raise {input
input : String- Raw JSON text describing async queue, batching, linger, and flush settings.
output
AsyncLoggerConfig- Parsed async runtime config value.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper parses only the async config portion, not the embedded sync
LoggerConfig. - Missing
max_pending,overflow,max_batch,linger_ms, andflushfields fall back to the same defaults used byAsyncLoggerConfig::new(...). - Parsed values then flow through
AsyncLoggerConfig::new(...), somax_batchandlinger_msreceive the same constructor normalization. - Overflow parsing accepts both
DropNewestand the compatibility aliasDropLatest. - Flush parsing accepts both
Neverand the compatibility aliasNone. - The error surface here is the general
Failurepath used by the async config utilities, including malformed JSON, non-object roots, wrong field types, and unsupported enum text. - Use this API when async policy comes from config text but sink choice is still assembled elsewhere.
How to Use
Here are some specific examples provided.
When Need Async Queue Policy From JSON
When async queue behavior is loaded separately from sync sink config:
let config = parse_async_logger_config_text(
"{\"max_pending\":8,\"overflow\":\"DropOldest\",\"max_batch\":3,\"linger_ms\":25,\"flush\":\"Batch\"}",
)In this example, async queue and flush policy are parsed from text into a typed config object.
When Need Alias-friendly Async Policy Parsing
When external config may use compatibility labels:
let config = parse_async_logger_config_text(
"{\"overflow\":\"DropLatest\",\"flush\":\"None\"}",
)In this example, parser aliases are accepted and normalized into the public enum values.
Error Case
e.g.:
If the JSON text is malformed, parsing raises an error.
If enum names such as
overfloworflushare unsupported, parsing raises an error.If a field is present with the wrong JSON type, parsing raises an error instead of silently coercing it.
Notes
Use this helper when only async policy is text-driven.
Use
parse_async_logger_build_config_text(...)when both sync logger config and async config come from the same JSON payload.Omitted fields fall back to the default async config values rather than causing a missing-field error.