Skip to content

Commit c91fb88

Browse files
author
developerworks
committed
Update supervisor config schema, docs, and validation tests
- Harmonize supervisor YAML config examples and configuration docs - Extend config schema handling in src/config and src/spec - Add/refresh config validation and docs sync tests
1 parent e95ce81 commit c91fb88

20 files changed

Lines changed: 117 additions & 66 deletions

examples/config/split/supervisor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ include:
77

88
supervisor:
99
strategy: OneForAll
10+
control_channel_capacity: 256
11+
event_channel_capacity: 256
1012

1113
policy:
1214
child_restart_limit: 10

examples/config/supervisor.local.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
supervisor:
22
strategy: OneForAll
33
escalation_policy: escalate_to_parent
4+
control_channel_capacity: 256
5+
event_channel_capacity: 256
46
dynamic_supervisor:
57
enabled: true
68
child_limit: 16

examples/config/supervisor.template.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ supervisor:
88
# Restart scope strategy for child failures.
99
strategy: OneForAll
1010

11-
# Optional supervisor-level escalation policy.
11+
# Optional fallback escalation policy used when child and group policies do
12+
# not define a more specific policy.
1213
escalation_policy: escalate_to_parent
1314

15+
# Control command channel capacity.
16+
# Recommended default: 256
17+
control_channel_capacity: 256
18+
19+
# Event broadcast channel capacity.
20+
# Recommended default: 256
21+
event_channel_capacity: 256
22+
1423
# Runtime dynamic child acceptance policy.
1524
dynamic_supervisor:
1625
enabled: true

examples/config/supervisor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
supervisor:
22
strategy: OneForAll
33
escalation_policy: escalate_to_parent
4+
control_channel_capacity: 256
5+
event_channel_capacity: 256
46
dynamic_supervisor:
57
enabled: true
68
child_limit: 16

manual/en/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ IPC checks (when `dashboard.enabled = true`):
105105
supervisor:
106106
strategy: OneForAll
107107
escalation_policy: escalate_to_parent
108+
control_channel_capacity: 256
109+
event_channel_capacity: 256
108110
dynamic_supervisor:
109111
enabled: true
110112
child_limit: 16

manual/zh/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ IPC(进程间通信)检查(当 `dashboard.enabled = true` 时):
105105
supervisor:
106106
strategy: OneForAll
107107
escalation_policy: escalate_to_parent
108+
control_channel_capacity: 256
109+
event_channel_capacity: 256
108110
dynamic_supervisor:
109111
enabled: true
110112
child_limit: 16

src/config/configurable.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use crate::{
2121
},
2222
spec::{
2323
child_declaration::ChildrenConfigSection,
24-
supervisor::{BackpressureConfig, EscalationPolicy, SupervisionStrategy},
24+
supervisor::{
25+
BackpressureConfig, EscalationPolicy, RECOMMENDED_CHANNEL_CAPACITY, SupervisionStrategy,
26+
},
2527
},
2628
};
2729

@@ -128,6 +130,20 @@ pub struct SupervisorRootConfig {
128130
#[schemars(!default)]
129131
#[serde(default)]
130132
pub escalation_policy: Option<EscalationPolicy>,
133+
/// Control command channel capacity.
134+
///
135+
/// Runtime capacity for queued supervisor control commands.
136+
/// Recommended default: 256.
137+
#[config(default = 256)]
138+
#[serde(default = "default_channel_capacity")]
139+
pub control_channel_capacity: usize,
140+
/// Event broadcast channel capacity.
141+
///
142+
/// Runtime capacity for supervisor event broadcast delivery.
143+
/// Recommended default: 256.
144+
#[config(default = 256)]
145+
#[serde(default = "default_channel_capacity")]
146+
pub event_channel_capacity: usize,
131147
/// Runtime dynamic child acceptance policy.
132148
#[config(nested)]
133149
#[serde(default)]
@@ -323,6 +339,11 @@ fn default_abort_wait_ms() -> u64 {
323339
1000
324340
}
325341

342+
/// Returns the recommended channel capacity.
343+
fn default_channel_capacity() -> usize {
344+
RECOMMENDED_CHANNEL_CAPACITY
345+
}
346+
326347
/// Returns the default event journal capacity.
327348
fn default_event_journal_capacity() -> usize {
328349
256

src/config/state.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ impl ConfigState {
362362
/// let yaml = r#"
363363
/// supervisor:
364364
/// strategy: OneForAll
365+
/// control_channel_capacity: 256
366+
/// event_channel_capacity: 256
365367
/// policy:
366368
/// child_restart_limit: 10
367369
/// child_restart_window_ms: 60000
@@ -433,8 +435,8 @@ impl ConfigState {
433435
spec.config_version = self.config_version();
434436
spec.supervisor_failure_limit = self.policy.supervisor_failure_limit;
435437
spec.escalation_policy = self.supervisor.escalation_policy;
436-
spec.control_channel_capacity = self.observability.event_journal_capacity;
437-
spec.event_channel_capacity = self.observability.event_journal_capacity;
438+
spec.control_channel_capacity = self.supervisor.control_channel_capacity;
439+
spec.event_channel_capacity = self.supervisor.event_channel_capacity;
438440
spec.backpressure_config = self.backpressure.clone();
439441
let group_members = derive_group_members(&self.children);
440442
spec.group_configs = self
@@ -508,8 +510,10 @@ impl ConfigState {
508510
/// Returns a deterministic version string for diagnostics.
509511
fn config_version(&self) -> String {
510512
format!(
511-
"supervisor-{:?}-policy-{}-{}-shutdown-{}-observe-{}-backpressure-{:?}-{}-{}",
513+
"supervisor-{:?}-channels-{}-{}-policy-{}-{}-shutdown-{}-observe-{}-backpressure-{:?}-{}-{}",
512514
self.supervisor.strategy,
515+
self.supervisor.control_channel_capacity,
516+
self.supervisor.event_channel_capacity,
513517
self.policy.child_restart_limit,
514518
self.policy.supervisor_failure_limit,
515519
self.shutdown.graceful_timeout_ms,
@@ -662,6 +666,14 @@ fn validate_lower_policy(
662666
fn validate_supervisor_root(
663667
supervisor: &SupervisorRootConfig,
664668
) -> Result<(), crate::error::types::SupervisorError> {
669+
validate_positive(
670+
supervisor.control_channel_capacity as u64,
671+
"supervisor.control_channel_capacity",
672+
)?;
673+
validate_positive(
674+
supervisor.event_channel_capacity as u64,
675+
"supervisor.event_channel_capacity",
676+
)?;
665677
if supervisor.dynamic_supervisor.child_limit == Some(0) {
666678
return Err(crate::error::types::SupervisorError::fatal_config(
667679
"supervisor.dynamic_supervisor.child_limit must be greater than zero",

src/config/tests/configurable_schema_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ fn supervisor_config_generates_schema_for_all_public_fields() {
2121
"supervisor",
2222
"strategy",
2323
"escalation_policy",
24+
"control_channel_capacity",
25+
"event_channel_capacity",
2426
"dynamic_supervisor",
2527
"enabled",
2628
"child_limit",

src/config/tests/configurable_template_test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ fn generated_template_contains_all_runtime_tunables() {
9999
for field in [
100100
"strategy",
101101
"escalation_policy",
102+
"control_channel_capacity",
103+
"event_channel_capacity",
102104
"dynamic_supervisor",
103105
"enabled",
104106
"child_limit",
@@ -170,6 +172,8 @@ fn generated_template_writes_runtime_default_values() {
170172

171173
for field in [
172174
"strategy: OneForAll",
175+
"control_channel_capacity: 256",
176+
"event_channel_capacity: 256",
173177
"child_restart_limit: 10",
174178
"child_restart_window_ms: 60000",
175179
"supervisor_failure_limit: 30",

0 commit comments

Comments
 (0)