Reorg introduce api package containing Entry interface#401
Conversation
08c3843 to
651c414
Compare
faebr
left a comment
There was a problem hiding this comment.
I really like the interface separation from the stateless ops. I always struggled to fully understand sharedEntryAttributes and this breaks it down! I assume the commented out functions in entry.go are the ones you will still implement right?
There was a problem hiding this comment.
should the leaf_variants also be parts of the api / interface package or would it make sense to take this implementation into another package so to only have the interface definitions in the api package?
There was a problem hiding this comment.
possible... lets add an issue to investigate that. Nothing I would want to also squeeze into this PR.
…centralize dispatch - extract entry validators into dedicated files (range, length, pattern, mandatory, min/max-elements) - keep validate package entrypoint focused on orchestration/result aggregation - introduce dedicated validator dispatch/registry file with shared ValidationFunc signature - precompute active validators once from config and pass through recursive processor tasks - simplify recursive validation path by executing only active validator functions per entry
e2324c9 to
eddffb1
Compare
8e2dcbd to
e90c167
Compare
alexandernorth
left a comment
There was a problem hiding this comment.
much prefer this approach :)
…tions Summary: Replace ad-hoc child creation with a canonical get-or-create API (`AddOrGetChild`) on the `Entry` interface and in `ChildMap`. Callers are updated to use the canonical `Entry` returned by the API so concurrent creators do not overwrite canonical children. Also add interactive path-completion support via `pkg/tree/ops/GetPathCompletions` and its integration test. Why: Previous usage assumed the caller's `Entry` instance becomes the canonical child. Concurrent creators could create duplicate or overwritten children. Centralizing canonicalization avoids subtle concurrency bugs and ensures a single canonical child entry per path name. API changes: - `pkg/tree/api/entry.go`: replace `AddChild(context.Context, Entry) error` with `AddOrGetChild(context.Context, Entry) (Entry, error)`; `NewEntry` now returns `api.Entry`. Implementation changes: - `pkg/tree/api/childMap.go`: add `AddOrGet` which acquires the lock and returns the canonical `Entry` if present, otherwise inserts and returns the new entry. - `pkg/tree/sharedEntryAttributes.go`: implement `AddOrGetChild` and use `childs.AddOrGet` so we don't overwrite an existing canonical entry. Update callers to use the returned `Entry` where appropriate. - Update ops to use the new API (`pkg/tree/ops/getorcreatechilds.go`, `pkg/tree/ops/checkandcreatekeysasleafs.go`, etc.). New feature: - `pkg/tree/ops/getpathcompletions.go` (new): provides path and key completions for interactive XPath-like paths. - `pkg/tree/getpathcompletions_test.go` (new): integration tests covering completion behavior.
GetIntentResponse with yet missing attributes
|
LGTM |
1 similar comment
|
LGTM |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Reorganizes the tree package by introducing a new
pkg/tree/apisurface and apkg/tree/constspackage, then updates the codebase to use those exported interfaces, types, and constants.pkg/tree/api) withEntry,LeafVariants, delete-path types, and non-revertive tracking; introducespkg/tree/opshelpers (e.g.,GetByOwner) and an ops interface.pkg/tree/constsand replaces many directtree.RunningIntentName/RunningValuesPrio/Replace*usages withconstsequivalents across datastore, targets, server, and tests.ShouldDelete,GetOrCreateChilds,ToJsonInternal),LeafVariantsaccessors, andTreeContextnow exposingSchemaClient,ExplicitDeletes, andNonRevertiveInfo.SdcpbPath.SdcpbPath()and updates callers, plus broad test updates to match new APIs and constants.