Repository navigation
Description
Feature Overview
The component model currently allows Service<T>s to be either be (a) required for dispatch or (b) optional, wherein a service is passed to a component if it is available at the time of dispatch. There is, however, no clear means by which a component optionally takes a Service wherein the service will be passed to the component if/when it has been installed. This feature request is to implement that functionality, facilitating cases where a Service should be considered optional but where execution of the service should not be delayed until the Service has been made available.
One example of this use case will be the Advanced Logger Component installing the AdvLoggerLocatorVariable. Once the interfaces are converted into services, the Advanced Logger Component will need to take this form of dependency on a variable write and variable protection service. The advanced logger component should not have to wait for these protocols to be installed to run.
Solution Overview
The solution could take multiple forms, but one solution I can think of would be to create a NotifyOnReady<> wrapper type that allows components to register closure callbacks stored in storage.rs.
pub fn entry_point(
self,
notify_on_ready_variable_policy, NotifyOnReady<Service<dyn VariablePolicy>>
) -> patina_sdk::error::Result<()> {
// Either stores callback in `storage.rs` callback database, or executes immediately
// if the service is already available
notify_on_ready_variable_policy.on_ready(|variable_policy_service| => {
// Use the variable policy service here
})
}Alternatives Considered
Another alternative would be to allow components to directly interact with a callback database in storage.rs, though that would make dependencies less clearly defined.
Urgency
Low
Are you going to implement the feature request?
I will implement the feature
Do you need maintainer feedback?
No maintainer feedback needed
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
kouchekiniad commentedon Sep 24, 2025
@Javagedes FYI
[-][Feature]: Notify-On-Ready Optional Services[/-][+][Feature]: Notify-On-Ready Optional Component Service Dependencies[/+]makubacki commentedon Sep 24, 2025
I'm not opposed to this, but wouldn't a simple solution be to move publication of
AdvLoggerLocatorVariableto its own component that does have dependencies on those variable services?kouchekiniad commentedon Sep 24, 2025
@makubacki That's definitely an option, but it would mean that all context that would normally be passed internally within an equivalent DXE driver would be exposed and accessible outside of that unit, which to me seems messy. It could also significantly increase the number of components and config structs that would be juggled by the dispatcher, though I'm not sure if that's a valid concern
kouchekiniad commentedon Sep 24, 2025
Also, since some platforms may not support, in this example, variable policy, this would require separate components for publishing and protecting the variable. This isn't necessarily an issue, but I could see this getting messy quickly for larger components where there may be additional dependencies between these sub-components.
makubacki commentedon Sep 24, 2025
First and foremost, putting a pointer to what should be an internal data structure in a globally accessible location (a UEFI variable) is already a leaky/hacky design. That's a pre-existing issue with advanced logger (and given the requirements - a large log buffer and protections available - such as memory and variable protections, it's managed to stick around).
In general though, I'd prefer to avoid "large components" that have a lot of dependencies.
Stepping back for this case, why should a logging service need to depend on a UEFI variable service? That seems weird in itself given the variable service likely wants to log.
A reason this happened in the C code was because drivers were standalone binary entities that were more costly to store in flash (each consumed a PE/COFF header, plus aligned sections, etc.) and it was very easy to keep attaching functionality to an existing entity with new libraries. That's not the case for Patina components where they are all compiled as code into a single image.
If that becomes an actual concern, then we'd have to redesign the component model. The goal for Patina (and components) is to write correct and easily testable software. If it becomes ncessary to group functionality together for the sole purpose of the infrastructure not being able to handle it that would be a problem. But, it shouldn't speculatively influence designs.
Separate components would not be necessary. We would want the variable protected and to require that the variable policy service be available to do so.
I haven't looked at this, but I'd expect a config set to the advanced loggger location during boot or a common library crate could be used to get what's needed to produce the variable.
In short, I could see the general request being useful but unless there is a compelling reason, I think isolating this to its own component with its unique dependencies accounted for in that component would make both advanced logger components cleaner and it easier to drop this UEFI variable mechanism in the future if desired.
kouchekiniad commentedon Sep 24, 2025
Perhaps the advanced logger locator case was a bad example, but I see your point. If the intent is to let the simpler dependency structure of multiple components replace, as emergent behavior, the more complicated dependency structures of equivalent DXE drivers, then I'm fully on board with your approach in this case.
I do think there may be cases where this feature would add functionality that fundamentally wouldn't be possible otherwise, such as a component that publishes a service that must change behavior if/once another service has been published, but I'll need to mull on this to see if I can come up with a practical example.
makubacki commentedon Oct 13, 2026
Given the discussion above and length of time this has been open, I'm going to close it as not planned. A clear use case still has not been pointed out versus using more granular components. A new feature request with renewed urgency can be opened if this is still an ask.