Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API #24

Open
charl opened this issue Nov 12, 2016 · 2 comments
Open

New API #24

charl opened this issue Nov 12, 2016 · 2 comments

Comments

@charl
Copy link
Contributor

charl commented Nov 12, 2016

A place for us to discuss ideas about improving the API.

@nemith has suggested:

I think i would like an Session.Exec that takes a interface{} that we can type assert. If we are given a string or byte slice then send it raw, if we get an object that can be XML encoded then encode it and send that. If we get something that matches the RPCMethod interface then send that. It would make it all a lot easier.

And:

Yes it's not very well designed and I would like to provide a way to do encoding/decoding as an interface making it even more transparent to get results.

@jonreyna
Copy link

Addressing the performance and allocation concerns in #11 by @nemith: Why not implement a session.Exec that uses reflection and takes an interface{}, and implement the more performant methods taking string or []byte parameters? This would allow the user of the library to choose which method to use. Benchmarks could be written for each method, and documented in the godoc and/or in the README.md.

Alternatively, we could benchmark the session.Exec that uses reflection, and if everyone agrees the performance penalty is acceptable, just modify the API accordingly.

I really like the idea of session.Exec(interface{}), because it would greatly simplify client code. There would have to be a priority on each reflect.Type though, and it would have to be well documented. Perhaps the netconf.RPCMethod interface would take first priority, and the fmt.Sringer interface would take last priority?

@nemith
Copy link
Collaborator

nemith commented Feb 18, 2018

Probably netconf.RPCMethod-> xml.Encoder -> string would make since. Calling fmt.Stringer sound like a bad idea after reading this 1+ year later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants