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

Support for arbitrary structs without explicitly registering them #47

Open
Stebalien opened this issue Dec 7, 2018 · 2 comments
Open

Comments

@Stebalien
Copy link
Contributor

To fully replace encoding/json, it would be great to be able to pass an arbitrary interface{} to refmt and have it auto-generate the necessary atlas entries.

What are the performance implications of this? I assume the tricky part here is caching these auto-generated atlases.

@warpfork
Copy link
Member

warpfork commented Dec 7, 2018

It's totally doable, just needs some implementation time.

The stdlib encoding/json package is a great reference for how to do the caching part. I've forgotten exactly how it works, but it's reasonably efficient and has all the hard concurrency parts straightened out already: it should be fairly easy to port.

I'd still like to make it an option at the Atlas scale for whether or not auto-generation for unknown types is allowed. In that case, we don't have to worry about the performance implications at all, because you could opt out of having it come up at all.

The main place for autogeneration to be invoked would be right about here:

// TODO here we could also invoke automatic atlas autogen, if configured to be permitted

I'm not sure if it would be better to then have those generated AtlasEntrys be placed directly into the current Atlas (that would cause the sync code to spread More Places...) or to keep a separate map for generated AtlasEntrys. Leaning towards the latter because it seems simpler to implement, and that map of generated entries actually should be global.

@Stebalien
Copy link
Contributor Author

SGTM

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

No branches or pull requests

2 participants