2.5 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| queue-config-to-json | api | config | 20260512 | Convert QueueConfig into a JSON value for export, persistence, or generated config tooling. |
|
Queue-config-to-json
Convert a typed QueueConfig into a JsonValue. This helper is the structured export path for synchronous queue wrapper configuration when callers want machine-readable config output.
Interface
pub fn queue_config_to_json(queue : QueueConfig) -> @json_parser.JsonValue {}
input
queue : QueueConfig- Queue wrapper configuration created in code or parsed from config text.
output
JsonValue- Structured JSON representation of the queue config.
e.g.:
pub fn queue_config_to_json(queue : QueueConfig) -> @json_parser.JsonValue {}
input
queue : QueueConfig- Queue settings to export.
output
JsonValue- JSON-exportable queue object.
Explanation
Detailed rules explaining key parameters and behaviors
- The output includes
max_pendingandoverflow. - Overflow is serialized using the supported config labels such as
DropNewestandDropOldest. - This helper is intended for config export rather than runtime queue inspection.
- The JSON shape matches the queue section accepted by
parse_logger_config_text(...).
How to Use
Here are some specific examples provided.
When Need Structured Queue Config Export
When queue settings should be embedded into a larger JSON payload:
let queue_json = queue_config_to_json(
QueueConfig::new(64, overflow=QueueOverflowPolicy::DropOldest),
)
In this example, callers receive a reusable JSON value instead of a final string.
When Need Roundtrip-friendly Config Data
When code generates queue policy and later persists it:
let value = queue_config_to_json(QueueConfig::new(16))
In this example, the exported shape stays aligned with the supported parser schema.
Error Case
e.g.:
-
If
max_pendingis very small, the config still serializes successfully even though runtime drops may happen more often. -
If callers need direct text output instead of a JSON value, they should use
stringify_queue_config(...)instead.
Notes
Notes are here.
-
This helper exports config data, not queue runtime metrics.
-
Use this API when downstream code expects
JsonValue. -
Pair it with
QueueConfig::new(...)for code-generated config. -
The output is suitable for persistence, testing, and generated configuration flows.