Retry invalidated cache property get after cache is invalidated#1807
Retry invalidated cache property get after cache is invalidated#1807sander-machado wants to merge 3 commits into
Conversation
1ae37b3 to
3bd8b25
Compare
|
@sander-machado thanks. Two questions upfront first:
|
|
But that approach probably only works if ObjectServer is used... |
I believe you meant |
Yeah good point, I'm thinking about a system with two fallbacks. If ObjectManager exists try to use that, otherwise if the service doesn't exist wait for it to appear and then finally just manually check on property get requests. Does that sound reasonable? |
That would solve the problem at hand (properties cache) but user will still have a proxy to a non-existant interface+object and any method calls will fail and they've also no way to know the state of the properties cache. Keeping that in mind, I'm starting to think that perhaps the best idea would be to provide some external API for this, that makes use of ObjectManager. Some sort of high-level wrapper around ObjectManager, a service proxy of sorts. 🤔 |
yeah I think the main underlying issue here actually is that you can receive an object from Proxy::new() that is actually invalid as well. Changing this would be a massive breaking API change, making But maybe having some higher level service proxy could be good idea regardless, it could then have a async method that returns the Proxy in question, that would not be an API change as well which is a plus. But existing users wouldn't get the fix for "free" edit: new is already async, was thinking of something else and got confused sorry, maybe new should simply Error out if the backing service doesn't exist? and we create a new method that's basically new + wait till it exists? |
That's not at all what I was proposing. It's not at all a catastrophe to to have proxies to in-existant interfaces (I believe other D-Bus APIs have the same "issue").
AFAIK ObjectManager is high recommended when your objects and interfaces are dynamic since it's a very bad API to add and (especially) remove objects/interfaces w/o notiying any clients and therefore it is quite widespread. Us providing a better interface for this, would further encourage people to implement it. With zbus, it's super easy to implement it even.
I think it'd be good to do both. In the proxy, we should keep it simple though and only care about service/name, and not complicate things with ObjectManager etc. ObjectManager would also be quite complicated and heavy to use correctly here. The interface doesn't have a This is why I think ObjectManager-based API should be an external umbrellla API for the whole service, so that it can scale and there isn't a lot of complication in the proxy. |
Yeah in our C++ libdbus wrapper the "proxy" just gets created but because it doesn't use caching it kinda just works because it's basically just a bunch of match rules. We migrate one of those over to rust and that's when I stumbled on this behavior which is very initiative in zbus. If you disable caching does zbus work the same? There's a comment on the API that gives you the property changed stream that it doesn't work without caching enabled (never actually tested it).
Yeah unfortunately for me we have our own version of ObjectManager API because it pre-dates ObjectManager so I would have to migrate. But if zbus actually works well it it, might be worth the investment. I would still like the basic case where it waits for the service to come online to be in the proxy though? Regardless of the ObjectManager support.
So as a suggestion, in this PR I see two ways I could implement the simple Proxy usecase.
Am I following your reasoning here? For the the ObjectManager stuff that should probably be a seperate "epic" or "issue" whatever you wanna call it? I can probably dedicate some time to once it's clear how you want it implemented. |
Yeah, idea2 seems good to me. We need to to also take into account service going down and up again (during which time the property values can change). |
When a proxy would be created before the interface that is was targeting would be created, while caching is enabled, the cache would be permanently poisoned. You could solve it by recreating the client but I felt like it could be easier. The main issue is that once cache.ready is invalid it will never recover. An idea I had was that it would fall through to doing a real call even if the cache is invalid and if it succeeds would "refresh" the cache.
Property streams will still not work but at least property gets will, we encountered this while developing and it seemed like small enough change that might help some people in the future.
Disclaimer this PR was made with assistance of claude.