-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
Hi @nyarly, thanks for getting back to this! In #183 (comment), I wrote
You went for Rust structs instead of Varlink definitions for the public API definition. I'd be curious about your perspective on the pros and cons of a Varlink vs. Rust representation of the public API. |
@curiousleo I think I missed that comment at the time. Let me look into using Varlink for this. |
One preliminary concern: is there a sensible way to make clear that there's the JSON Varlink (part of the public interface) and the internal Varlink (which is private and changeable)? |
There should be a new, separate Varlink file for the public interface. The existing Varlink file with the private interface should probably get a big banner at the top saying "this is a private interface; don't use it; may change at any time without notice". |
So, two varlink interfaces. New one called I'm looking today at how varlink.rs provides serialization without wire protocol... |
...oh, the generated message structs are |
Okay, so here's a line of thought @curiousleo @Profpatsch - I started working through a varlink Events message for serialization to JSON. It'll be straightforward to replace the Rust structs with that message, I think. But, wouldn't it make sense to fully pull the Event interface out of the internal varlink definition and have the daemon use the same messaging? If we're exposing the message via varlink, it would be surprising (I would be surprised, at least) not to make direct varlink integration possible, and for that you need a method and a place to make the requests. I think I'd be happy with But, it would fix the Event message in the interface... I'm not sure that's terrible, since it's effectively fixed already. No significant change can be useful without exposing it in the output, anyway. In this case, I'd also argue against changing the structure of the message, since the "type safety" argument isn't as strong when the message is meant to be consumed by jq parsers. |
I am not 100% sure what you're proposing concretely here. What I want to make sure is that (1) the public interface is well-defined, ideally as Varlink in a separate file; (2) no internal declarations (Varlink or Rust) leak into the public interface.
I don't think this argument is very strong. Every JSON interface has a "type" of some sort - when you call a JSON API, there are usually fields that you expect in the answer. The simpler the answer to the question "which fields can I expect?", the better. The proposed structure in #183 (comment) makes this answer very simple, which is useful no matter where the output is used. |
As far as I can see, all of this is included in the current lorri release. We haven’t made the json format stable yet, but we could in the future. |
For reference: current lorri release: https://github.com/nix-community/lorri/releases/tag/1.4.0 |
First task of issue #324
Overview
Creates a dedicated DTO format for JSON, so we can use that format as part of the public API.
Checklist
release.nix
(seerelease.nix
for instructions)