-
Notifications
You must be signed in to change notification settings - Fork 2
TopicMappingService: Proactively check type compatibility #83
Copy link
Copy link
Closed
Labels
Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Relates to one of the `ITopicMappingService` interfaces or implementations.Priority: 1Severity 1: MinorStatus 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: ImprovementImproves the functionality or interface of an existing feature.Improves the functionality or interface of an existing feature.
Milestone
Metadata
Metadata
Assignees
Labels
Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Relates to one of the `ITopicMappingService` interfaces or implementations.Priority: 1Severity 1: MinorStatus 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: ImprovementImproves the functionality or interface of an existing feature.Improves the functionality or interface of an existing feature.
Currently, the
TopicMappingServicemaps associated topics, and then evaluates if they’re compatible with the target type. If they’re not, the association is discarded.Instead, it would be preferable to lookup the target
Typeahead of time, using theITypeLookupService, and only map the topic if the resulting type will be compatible. That way, unnecessary mappings aren’t performed.This has its drawbacks. It means looking up the type in each of the several places where we call to map associations. But with the type, we can call the overload of
MapAsync()that accepts aTypeparameter to avoid it needing to callITypeLookupServiceagain. And that prevents the need to conditionally call differentMapAsync()overloads, as we do today in order to support[MapAs()]. Plus, we may be able to centralize this logic via a helper method.This makes it easier to take an eager modeling strategy when the types are unknown, having confidence that type mismatches will be filtered out with comparatively little performance overhead. By contrast, the cost of this filtering today is expensive since the entire object—and, potentially, it’s associations!—needs to be mapped, independent of whether or not it’s used.