Skip to content

Commit 4b26281

Browse files
denikIsaac
andcommitted
direct: document auto-generated copiers in dresources README
Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 8829284 commit 4b26281

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎bundle/direct/dresources/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ Declaring a field under `hashed_fields` in `resources.yml` makes the engine pers
7575

7676
## RemapState is a dumb copy; DoRead owns all remapping
7777

78+
Most resources do not need a `RemapState` method at all. When `StateType` is a plain subset
79+
of `RemoteType`, the framework auto-generates the copy from the two types: `buildCopiers`
80+
(in `all.go`) compiles a copier per resource at package init, matching fields by JSON name,
81+
filtering `ForceSendFields`, and applying only lossless conversions. Anything it cannot copy
82+
safely (a kind-changing conversion, a mismatched struct shape) fails at load, so a resource
83+
that needs real logic surfaces as a build error rather than silent drift. Write a `RemapState`
84+
method only for that logic (derived fields, renames, per-field `ForceSendFields` rules); the
85+
rest of this section governs those hand-written overrides.
86+
7887
`RemapState` converts `RemoteType` to `StateType` only because `StateType` is typically a
7988
subset of `RemoteType`. It must be a field-by-field copy (or no-op), never a place for
8089
logic. In particular, do not remap a differently-named field there (e.g. `state.x = remote.status.x`).

0 commit comments

Comments
 (0)