Breaking changes merged to main tomorrow #44
Replies: 3 comments 2 replies
-
About 1) If the instance of the Selection has a meaning beyond its content using the pointers sound fine. About 2) I think its always easier in go to add "error" as an additional return value than hide it in an object you return. About 4) You mean directly implement the interface instead of using the "Basic/Extend" helpers? Not sure what you mean with "Reflect" will be deprecated, because its THE central helper to map a go data structure to yang/restconf. Comment for 4) There are a LOT of "magic constants" (mostly strings) in this code, maybe some field values should not be string but a derived type with constants defined on it? |
Beta Was this translation helpful? Give feedback.
-
There is now nodeutil.Node which uses reflection to implement node.Node
which is the interface. There is overlap in functionality between
nodeutil.Node and nodeutil.Reflect and I plan to deprecate the latter.
Re: magic constants
Let me know which you think should be turned into constants
…On Mon, Aug 21, 2023, 3:42 AM Henning Rogge ***@***.***> wrote:
About 1) If the instance of the Selection has a meaning beyond its content
using the pointers sound fine.
About 2) I think its always easier in go to add "error" as an additional
return value than hide it in an object you return.
About 4) You mean directly implement the interface instead of using the
"Basic/Extend" helpers? Not sure what you mean with "Reflect" will be
deprecated, because its THE central helper to map a go data structure to
yang/restconf.
Comment for 4) There are a LOT of "magic constants" (mostly strings) in
this code, maybe some field values should not be string but a derived type
with constants defined on it?
—
Reply to this email directly, view it on GitHub
<#44 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACA7VMRLUHVWZ2QGR4XY3XWMGMRANCNFSM6AAAAAA3XVCQ5Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
yes. sans your convert stuff which i'll bring over, i'm not aware of
anything missing but i could be missing something. it already supports
getting or setting fields via methods which nodeutil.Reflect did not.
…On Tue, Aug 22, 2023 at 4:44 AM Henning Rogge ***@***.***> wrote:
I assume that you aim for feature parity of nodeutil.Node before phasing
out nodeutil.Reflect?
—
Reply to this email directly, view it on GitHub
<#44 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACA7QRK3BP352VC4MZX3DXWRWOJANCNFSM6AAAAAA3XVCQ5Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
1. node.Selection as a pointer
Summary:
Almost everywhere you reference a node.Selection it is likely now a *node.Selection
Rationale:
When passing object references to python, I needed to associate which selection was which and pointers were more useful. Go code saw an improvement when changed, many things simplified
2. Replacing Selection.LastErr with returning an error
Summary:
Methods on Selection like Find or Upsert return err and not another Selection
Rationale:
More idomatic Go. LastErr was written 8 years ago before I knew better.
3. New method node.Release
Summary:
You can now tell when a node is no longer in scope even for reads.
Rationale:
Needed to know which nodes can be garbage collections and no longer referenced in Python. This was also addressing a long standing request for Go for implementing read locks.
4. New way to use reflection to implement a Node
Summary:
Use nodeutil.Node instead of nodeutil.Reflect. nodeutil.Reflect will be deprecated at some point.
Before:
https://github.com/freeconf/yang/blob/lang/nodeutil/schema.go
After:
https://github.com/freeconf/yang/blob/lang/nodeutil/schema2.go
Docs:
http://localhost:9876/docs/examples/node-reflect/ but more docs will be forthcoming.
Rationale:
nodeutil.Reflect required a lot of code and extending it was getting complicated. Inspiration came from reimplementing reflection in Python and finding this approach much easier.
Beta Was this translation helpful? Give feedback.
All reactions