We’re almost done with the feature, thanks to a lot of good work by @Chipaca. Today we had what I think is the last exchange on details of the API and user interface, which I’m copying below for awareness and for our own future benefit:
<Chipaca> niemeyer: let me know when you have 15’ to go over stuff?
<niemeyer> Chipaca: Back just now
<Chipaca> niemeyer: so, working from the commandline in, “snap status” as it stands in the PR is OK, yes?
<niemeyer> Chipaca: Double checking
<Chipaca> niemeyer: thank you
<niemeyer> Chipaca: The output sounds sane… I’m just wondering a bit about the command name itself
<niemeyer> Chipaca: I wonder if it feels too much like “snap status” would result in what we have as “snap list”
<niemeyer> Chipaca: (the status of snaps in the system)
<niemeyer> Chipaca: WDYT?
<Chipaca> niemeyer: a little bit, yes
<Chipaca> niemeyer: OTOH we decided against “snap service status” AFAIK
<Chipaca> niemeyer: and if “snap status” feels like this, I reckon so will “snap restart”
<niemeyer> Chipaca: Indeed, and we have the same sort of ambiguity on enable/disable
<niemeyer> Chipaca: I guess status is fine from that angle, and the analogy of systemctl is definitely a plus
<niemeyer> Chipaca: Were you thinking about something specific when you asked?
<Chipaca> niemeyer: no, just walking over the changes i need to make to be sure
<Chipaca> layer by layer i mean
<niemeyer> Chipaca: I think we’re good on that one… I do wonder how we’ll represent timers when they come
<niemeyer> Chipaca: Sounds like it’d make some sense to have them there…
<Chipaca> niemeyer: I don’t understand your concern there, but that might be because I don’t know what timers are for snapd
<Chipaca> I know what they are in systemd
<niemeyer> Chipaca: I think that’s exactly my concern
<niemeyer> Chipaca: (the fact we don’t have a clear view, which might lead to awkward corners soon)
<pedronis> well people asked to have systemd(-like) timers supported for snaps
<Chipaca> niemeyer: timers can be active and enabled too, fwiw
<niemeyer> Chipaca: Right, that sounds sane
<niemeyer> and may be stopped/etc
<Chipaca> niemeyer: anyway, going one step further in, we’d have an Apps method on clients, that takes a list of things, and an options struct
<niemeyer> Chipaca: Yeah, singular I think
<niemeyer> AppOptions?
<Chipaca> niemeyer: singular…?
<niemeyer> I think that’s what we do on other cases… double checking
<Chipaca> niemeyer: and, here i’m not so sure: the options struct has an All bool, which if false means just services?
<niemeyer> Argh… we have ChangesOptions… we should really fix that one
<Chipaca> why?
<Chipaca> it’s Options
<niemeyer> Yeah, maybe
<Chipaca> especially given that we used to have Change and Changes, ChangesOptions and ChangeOptions are clearly different beasts
<niemeyer> Yeah, that’s actually the issue
<niemeyer> Often those option methods are useful in the context of a single thing
<niemeyer> Let me try to find an example
<niemeyer> func (client *Client) Install(name string, options *SnapOptions) (changeID string, err error) {
<niemeyer> vs.
<niemeyer> func (client *Client) InstallMany(names []string, options *SnapOptions) (changeID string, err error) {
<niemeyer> The options are snap-related, the thing, rather than method-specific
<niemeyer> thus ChangeOptions, AppOptions, etc
<niemeyer> Similarly, although we have ChangesOptions, we call it ChangeSelector in one of its fields
<niemeyer> With that background, yeah, indeed I’d suggest going with the singular, and eventually fixing ChangesOptions to agree
<Chipaca> So Apps([]string, AppOptions)?
<niemeyer> Yeah
<Chipaca> ok
<Chipaca> niemeyer: and would the options struct has an All bool, which if false means just services?
<niemeyer> Chipaca: The opposite case feels more natural: return all by default as it’s an /apps endpoint, and allow constraining to services by providing {Service: true}
<Chipaca> ok
<niemeyer> Chipaca: That opens the door for us to have a special kind of service which is hidden as well
<Chipaca> niemeyer: and that translates to select="", “all”, and “services” (with the two first ones being synonymous)
<niemeyer> Chipaca: and which we uncloak via a future All field
<niemeyer> Chipaca: Similar to what we do with snaps
<Chipaca> ah, so no select=all as synonymous for =""
<Chipaca> niemeyer: ok so far?
<niemeyer> Chipaca: Yeah, I’d keep just “” and “service” (again singular due to precedence in /v2/snap’s refresh)
<niemeyer> s/refresh/select
<niemeyer> Chipaca: For that latter use case, perhaps just “” and “service”
<niemeyer> Chipaca: Again singular (precedence in /v2/snaps’s select
<niemeyer> Thanks irccloud
<Chipaca> niemeyer: precedent, not precedence, i assume
<niemeyer> It told me it couldn’t send my messages, and then did it later
<Chipaca> ok
<Chipaca> but note that snaps uses adjectives
<Chipaca> bah, not even
<Chipaca> in snap’s select it’s “refresh” or “private”
<Chipaca> uhm
<Chipaca> sorry, that’s in find
<niemeyer> Chipaca: Sort of… I think it’s a similar use case… “the snap is a refresh… the snap is private… the app is a service”
<Chipaca> in snap it’s “all” or “enabled”
<niemeyer> Chipaca: Sorry, I was really thinking of find
<Chipaca> ok, singular
<Chipaca> niemeyer: then, inside daemon, there’s the call to the helper that right now has a struct. I think I’ll change that to mirror the client’s options, for less surprises.
<niemeyer> Chipaca: Looking
<niemeyer> Chipaca: You mean the wantedAppInfo?
<Chipaca> yeap
<niemeyer> Chipaca: +1
<niemeyer> Chipaca: I’m tempted to suggest “snap services”… I’ve been dueling with myself for the past 30 minutes on it
<niemeyer> Chipaca: Part of the question is: are timers services as well?
<niemeyer> I suspect that as far as systemd is concerned, they are not
<Chipaca> niemeyer: they are distinct
<niemeyer> Chipaca: So will we have a {Timer: true} flag?
<Chipaca> niemeyer: although in systemd a timer is associated with a service of the same name
<niemeyer> /o
<Chipaca> niemeyer: that is, the timer is just a timer
<Chipaca> niemeyer: when it fires, it runs the service with the same name
<pedronis> I doubt we would model it that way though
<Chipaca> correct
<Chipaca> niemeyer: (you can change which unit it fires, but the default is the one with the same name)
<niemeyer> I guess the app would be a timer and a service then?
<Chipaca> niemeyer: an app would be … Daemon: timer ?
<Chipaca> probably not because the service will have its own daemon:
<Chipaca> niemeyer: a daemon can have a timer?
<niemeyer> Chipaca: I was thinking of just having something like Schedule:
<niemeyer> Chipaca: Or simliar
<Chipaca> yup
<Chipaca> so a service would have a timer / schedule / thing
<Chipaca> makes sense to me
<niemeyer> Chipaca: We might imply “Daemon: timer” in that case perhaps?
<Chipaca> niemeyer: no because the service can be one-shot or notify or …
<niemeyer> Chipaca: Or would it make sense for something to be a daemon and a timer?
<niemeyer> Chipaca: Ah, okay, combined even in that sense… nice
<Chipaca> niemeyer: man systemd.timer fwiw
<Chipaca> niemeyer: also
<niemeyer> Chipaca: Yeah, I’m friends with that one… have been trying to find a good syntax for ourselves
<Chipaca> niemeyer: systemctl list-timers
<niemeyer> Chipaca: Thanks, hadn’t seen that one
<Chipaca> niemeyer: and i’d expect we’d want something similar, maybe under ‘snap timers’
<Chipaca> but, dunno
<niemeyer> Chipaca, pedronis: Okay, so, what’s the experience we want? Do we show timers on “snap status/services” output?
<Chipaca> because, dunno what timers are for snap
<niemeyer> Chipaca: +1 on “snap timers”
<Chipaca> niemeyer: if a service has a schedule, maybe include a “last run” or “next run” column?
<Chipaca> niemeyer: or a “see snap timers”?
<Chipaca> i mean
<Chipaca> no, i wouldn’t show timers as lines in ‘snap status’ output
<Chipaca> I’d show the services the timers fire, though
<niemeyer> Chipaca: Or perhaps just “Schedule”, with the actual string, and leave the specialized output for “snap timers”
<Chipaca> niemeyer: that sounds reasonable
<niemeyer> Chipaca: Okay, thanks, that gives much better understanding of what’s to come… so back to your original question:
<niemeyer> Chipaca: I think the output is mostly fine… a couple of points to ponder about:
<niemeyer> 1. Should we always have the first field? That makes it more tooling-friendly (think awk, grep, …)
<niemeyer> 2. Would it be useful to have Daemon with the value of that field?
<niemeyer> 3. I’m slightly conflicted about the name of the “Service” header… not sure if “App” would make it more clear or more confusing
<Chipaca> 1. i think yes, although i’m not sure it makes sense for it to be split
<Chipaca> 2. i don’t think Daemon tells the user of the app anything they need to know, no
<Chipaca> 3. i think Service is a little clearer than App, but not by a wide margin
<niemeyer> Okay… for 1, should we just have it always then?
<niemeyer> For 2, sounds good
<Chipaca> 1., yes i think so
<niemeyer> 3. Okay
<niemeyer> Chipaca: Sounds like we have a plan then!
<Chipaca> niemeyer: one last question: about the split of AppInfo and ServiceInfo in the client libs. It’s mainly driven by the desire for the json to be nice and clean for non-service apps, and nice and explicit for service apps
<niemeyer> Chipaca: I understand, but I also see value in the conceptual flattening… we’ve already decided to make them look alike long ago, and it earned us many bonus points in terms of having plugs/etc handling not care, being able to have commands and services, etc
<niemeyer> Chipaca: I think this is just being more honest about that internal representation, and passing the advantage of that flattening on to the client
<niemeyer> Chipaca: It’s analogous to systemd’s “units”, if you see what I mean
<niemeyer> I’m sure somebody complained about “starting a mount point”, but hey, the flat CLI is nice
<Chipaca> hmm
<Chipaca> niemeyer: in systemd, status of a unit (that is, the common ancestor of services, mountpoints, timers, …) makes sense
<Chipaca> niemeyer: whereas our apps are very distinct beasts
<Chipaca> but, i’ll flatten it
<Chipaca> no worries
<niemeyer> Chipaca: Not really… we do have a bunch of common ground for apps
<niemeyer> Chipaca: plugs and slots, security profiles, etc etc
<niemeyer> Chipaca: Thanks!
<niemeyer> Chipaca: Ah, and I suggest going with “snap services”, given all of that useful background
<Chipaca> ok
<Chipaca> but not right now. Right now, time to walk the dog, and think of dinner, and maybe a beer
<Chipaca> o/
<niemeyer> Chipaca: Sounds great, thanks for the chat… I’ll copy that conversation into the forum
<Chipaca> tks
<Chipaca> that’s another thing that’s harder to do in a hangout