You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
developerworks
committed
Update child spec builder implementation and docs
- Improve child spec builder implementation and test coverage
- Align example child spec builder usage with implementation
- Update English and Chinese child spec builder documentation
Copy file name to clipboardExpand all lines: manual/en/child-spec-builder.md
+36-14Lines changed: 36 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,9 @@ Legacy code may still mutate fields after construction. New code should prefer t
31
31
| Method | Purpose | Default highlights |
32
32
| --- | --- | --- |
33
33
|`worker(id, name, kind, factory)`| Async or blocking worker | Matches `ChildSpec::worker`: `Transient` restart, `Critical` criticality, `TaskRole::Worker`, and so on |
34
+
|`service(id, name, kind, factory)`| Long-running service | Based on worker defaults: `TaskRole::Service`, `Critical` criticality |
35
+
|`job(id, name, kind, factory)`| Finite job | Based on worker defaults: `TaskRole::Job`, `Optional` criticality |
36
+
|`sidecar(id, name, kind, factory, sidecar_config)`| Sidecar attached to a primary child | Based on worker defaults: `TaskRole::Sidecar`, writes `sidecar_config`, and automatically adds the primary child dependency |
|`new(id, name)`| Minimal skeleton | Sets only `id` / `name` plus baseline policies; caller must add `kind` and, for workers, `factory`|
36
39
@@ -40,6 +43,8 @@ Legacy code may still mutate fields after construction. New code should prefer t
40
43
| --- | --- |
41
44
|`build()`| Takes the inner `ChildSpec`, calls `validate()`, returns `Ok(spec)` or `SupervisorError`|
42
45
46
+
All entry methods and setters return `ChildSpecBuilder`, which means construction is still in progress. Only `build()` consumes the builder and returns the final `ChildSpec`.
47
+
43
48
There is **no**`build_validated()`. Validation is always performed inside `build()`.
44
49
45
50
`ChildSpec::worker(...)` also returns `Result<ChildSpec, SupervisorError>` via `ChildSpecBuilder::worker(...).build()`.
When `task_role = Sidecar`, you must also set `sidecar_config`, or `build()` validation fails:
117
+
Sidecars attached to a primary child should prefer `sidecar(...)`. This entry writes `sidecar_config` and automatically adds the primary child dependency:
0 commit comments