I feel like this is probably a FAQ, but I failed to find a document which outlines it.
I’ve got a function in a reactive charm like this
@when_any("config.changed.foo", "config.changed.bar") @when_all("config.set.foo", "config.set.bar", "website.available") def write_apache2_config(apache): foo = config().get("foo") bar = config().get("bar") config = "..." apache.send_site_config(config)
The problem is obviously that if I want to change
config the change isn’t applied due to the
changed guards. As a matter of style, is it normal to write reactive charms so that they “reset the world” and this would be called with every hook invocation? Or is there another best practice? I’d be worried in general about things like unnecessary reloads or just running potentially expensive code that isn’t necessary and takes resources away from the workload, if I apply this to the whole charm.
I suppose unnecessary reloading is easier to handle with the operator framework, as you can much more easily retrieve the previous values of things to see if they’ve changed. But I’m not using that here, at least not yet (I’d miss the library of layers for sure).