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
Code-generate a golang semantic layer on top of arbitrary JSON-LD contexts (Formerly: compile time) #48
Comments
Thanks for filing this! Yes I've been thinking on and off about what a 1.0 implementation would look like. So far the design choices I've imagined are:
The original idea for why interfaces like
Now those reasons have turned out to be fairly brittle. The first one would make sense if they were defined in the All the above would be fixable in a major release, in 1.0.0. Luckily, the compilation time & resource issue may be addressable in major version 0. The bulk of the compilation time by far should be the fact that the library generates The way I initially implemented
If you want me to tackle this sooner, please say so. The only 2 issues not from me on this library are about this topic, so I am now very receptive to prioritizing this highly. Finally, FYI there are |
Haha yeah, that's what I thought when I looked into the
It would indeed be really nice to have a highly abstract representation. Maybe even something that is capable of generating the representation from JSON-LD specs. This is something Im very open to collaborate on.
yeah I saw that, that's why I mentioned them (in an ambiguous way tho).. I don't want to implement anything on top of ActivityPub right now. I simply want to support the overall adaption for now. So no need to change your prioritisation. I think you didn't answer this question
And how would a developer be able to add custom types? |
The file
Right now, it requires modification of
The I understand this is a bit of a complex set up. I don't think this is the setup I would use a second time. However, my logic when I first set out to do the implementation was along the lines of "It's OK if this is difficult because I don't want ActivityPub apps creating new types willy-nilly". I had no idea that the passion for federating git servers would come so quickly nor so strongly, so in hindsight it probably was a wrong decision. I'm happy for collaboration; I just haven't sat down to create a Would you be fine if I split out the |
I am also interested in direct JSON-LD to Go generation. |
I think the initial step could be handled with github.com/kazarena/json-gold
I really don't want disrupt your workflow and I guess the generation process will be kinda experimental in the beginning. It will take a while until we agreed on things, as there are multiple ways on how to implement it.
That's the question. Your interfaces are very implementation specific, which is totally fine, but in order for others to be able to write custom en/decoding it would be nice to have the highest possible abstraction. Which is something we might not even need interfaces for. Let's say you want to iterate over a list of links. In a very abstract fashion that could be done like so for _, item := range actor.Followers {
println(item.Link.Href)
} Independent of if the Link was encoded as a IRI, string or might even object initially. Which would be something that would be handled by an en/decoding implementation. |
Great suggestion @zet4! I will definitely look into this library.
Another good suggestion, @21stio. I did look into that initially, however from what I could tell it is meant to operate on JSON-LD data and transform it using some known algorithms. It does not solve the semantic layer problem. That is where the Now that the code generation can create semantic layers, it could be applied itself on JSON-LD, which may require a preprocessing using json-gold to create a normalized (some kind of "expanded") context. If that's even the best path forward
That's fine, since this issue has turned out to be very focused on a feature I can only best describe as "Code-generate a golang semantic layer on top of arbitrary JSON-LD contexts" I will rename it as such. I'll break out the compile time and I'll add the API bit as another issue. I've addressed it below, but would welcome tackling it after this problem is solved (as the API would be a subset of the API being code-generated). Finally, will add an issue to add a
The interfaces are needed only for the
The "most abstract interface" for someone wanting to still leverage the |
Refocused #42.
Created #50.
Created #51. |
Quick summary after adjusting the issues. The current system is:
The next step is to scope what areas and identify what specific problems should be solved as part of this effort. I welcome everyone's input. Note that if this gets sufficiently generic, I am not opposed to breaking it out of the |
I think I spotted a little issue in the way By now I think decoding is impossible without normalising the input before. |
FYI, this is a part of the v1.0.0 release. To quickly summarize, I've been busy creating a different version of the code-generation tool that will be able to take in a special |
In a previous comment I mentioned:
What it will look like now:
|
The latest merge into tools/exp does this now. |
Hey,
I had a look into vocab.go. On my machine it adds about 40s of compile time.
I have a couple of questions and ideas how to reduce the file size, but Im not exactly sure how they impact the compile time actually.
Why are there interfaces for all the types? Are there more than one implementation for them?
What about adding more generic interfaces, like Serializer and Deserializer?
e.g.
What about dumping all the types that can be represented as an Object (like Note, Page)?
The text was updated successfully, but these errors were encountered: