Files
BitLogger/docs/api/queue-config-to-json.md
T
2026-05-12 13:20:36 +08:00

2.3 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
json
public

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.

Explanation

Detailed rules explaining key parameters and behaviors

  • The output includes max_pending and overflow.
  • Overflow is serialized using the supported config labels such as DropNewest and DropOldest.
  • 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_pending is 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.

  1. This helper exports config data, not queue runtime metrics.

  2. Use this API when downstream code expects JsonValue.

  3. Pair it with QueueConfig::new(...) for code-generated config.

  4. The output is suitable for persistence, testing, and generated configuration flows.