freeconf / restconf

Implementation of RESTCONF Management protocol - IETF RFC8040
Apache License 2.0
29 stars 9 forks source link

Feature request: Improve reflection support #40

Open rFronteddu opened 1 year ago

rFronteddu commented 1 year ago

I am no expert on reflection in go but I was wondering if you had any plan to support reflection for base types such as the example that follows. I was surprised to have to use a custom parser (albeit a simple one) to parse a list of string and integers.

    list bar {
        key foo;
        leaf foo {
            type int32 {
                range "0..120";
            }
        }
        leaf baz {
            type string;
        }
    }
dhubler commented 1 year ago

Lists are hard, but I think if everything lined up, reflection would handle that, but i am not sure. I have found that reflection really is one of the most important parts and I am committed to any motion to improve it.

There was a contribution for registering for field base types that might help you https://freeconf.org/docs/examples/node-reflect/#field-coersion

On Sat, Jul 22, 2023 at 2:32 PM Roberto Fronteddu @.***> wrote:

I am no expert on reflection in go but I was wondering if you had any plan to support reflection for base types such as the example that follows. I was surprised to have to use a custom parser (albeit a simple one) to parse a list of string and integers.

list bar {
    key foo;
    leaf foo {
        type int32 {
            range "0..120";
        }
    }
    leaf baz {
        type string;
    }
}

— Reply to this email directly, view it on GitHub https://github.com/freeconf/restconf/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACA7VRJGTQ7ZBZHHI2NW3XRQMD5ANCNFSM6AAAAAA2T7R73Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rFronteddu commented 1 year ago

I will be studying reflection in Golang soon. If I have some time I will try to cook something.

dhubler commented 1 year ago

Help would be appreciated, even if it is just reporting github issues like:

This would work: {insert YANG here} from: {insert go code here}

Go reflection is tricky, but the bigger challenge by far is all the variations that are inherent with trying to coerce data from code to a fixed schema. In addition, I've used a lot of serializers that are messy and confusing and this is an area I'll have a lot of opinions on.

On Sat, Jul 22, 2023 at 9:57 PM Roberto Fronteddu @.***> wrote:

I will be studying reflection in Golang soon. If I have some time I will try to cook something.

— Reply to this email directly, view it on GitHub https://github.com/freeconf/restconf/issues/40#issuecomment-1646721447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACA7WF5ROZTOPQOYWAABDXRSAJFANCNFSM6AAAAAA2T7R73Y . You are receiving this because you commented.Message ID: @.***>