| 1 | package control |
| 2 | |
| 3 | // TracksModelSettings reports whether the host supplied a live configuration |
| 4 | // observer. Unmanaged controllers have no settings I/O to perform on admission. |
| 5 | func (c *Controller) TracksModelSettings() bool { return c.modelSettings.current != nil } |
| 6 | |
| 7 | // ModelSettingsState compares this immutable runtime with current disk config. |
| 8 | // It is intentionally separate from provider-visible messages and metadata. |
| 9 | func (c *Controller) ModelSettingsState() (applied, desired string, err error) { |
| 10 | if c.modelSettings.current == nil { |
| 11 | return "", "", nil |
| 12 | } |
| 13 | desired, err = c.modelSettings.current() |
| 14 | return c.modelSettings.revision, desired, err |
| 15 | } |
| 16 | |
| 17 | // ModelSettingsSourceRevision identifies an immutable Desktop resolver bundle. |
| 18 | // It is transport bookkeeping only, never part of the conversation. |
| 19 | func (c *Controller) ModelSettingsSourceRevision() string { return c.modelSettings.sourceRevision } |
| 20 | |
| 21 | // controllerModelSettings keeps the immutable snapshot and its host admission |
| 22 | // callback together for the lifetime of one controller. The callback is guarded |
| 23 | // by Controller.mu; snapshot fields are immutable after construction. |
| 24 | type controllerModelSettings struct { |
| 25 | revision string |
| 26 | sourceRevision string |
| 27 | current func() (string, error) |
| 28 | beforeInboxDispatch func(*Controller) (func(), error) |
| 29 | } |
| 30 | |
| 31 | func newControllerModelSettings(opts Options) controllerModelSettings { |
| 32 | return controllerModelSettings{ |
| 33 | revision: opts.ModelSettingsRevision, |
| 34 | sourceRevision: opts.ModelSettingsSourceRevision, |
| 35 | current: opts.ModelSettingsCurrent, |
| 36 | beforeInboxDispatch: opts.BeforeInboxDispatch, |
| 37 | } |
| 38 | } |
| 39 |