-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to have a common interface for InUpdate Callback (#451)
* Refactoring to InUpdate * Update BaseAspectRoutingResource * Fixed errors * Addressed comments * Addressed comments * Removed preupdate * Removed pre-update name * Missed updating a method name * Comment back * Addressed comments * Added java doc * Added comments and fixed method names --------- Co-authored-by: Rakhi Agrawal <[email protected]>
- Loading branch information
Showing
17 changed files
with
275 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
dao-api/src/main/java/com/linkedin/metadata/dao/ingestion/AspectCallbackRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.linkedin.metadata.dao.ingestion; | ||
|
||
import com.linkedin.data.template.RecordTemplate; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import javax.annotation.Nonnull; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
/** | ||
* A registry which maintains mapping of aspects and their Aspect Routing Client. | ||
*/ | ||
@Slf4j | ||
public class AspectCallbackRegistry { | ||
|
||
private final Map<Class<? extends RecordTemplate>, AspectCallbackRoutingClient> aspectCallbackMap; | ||
|
||
/** | ||
* Constructor to register aspect callback routing clients for aspects. | ||
* @param aspectCallbackMap map containing aspect classes and their corresponding cleints | ||
*/ | ||
public AspectCallbackRegistry(@Nonnull Map<Class<? extends RecordTemplate>, AspectCallbackRoutingClient> aspectCallbackMap) { | ||
this.aspectCallbackMap = new HashMap<>(aspectCallbackMap); | ||
log.info("Registered aspect callback clients for aspects: {}", aspectCallbackMap.keySet()); | ||
} | ||
|
||
/** | ||
* Get Aspect Callback Routing Client for an aspect class. | ||
* @param aspectClass the class of the aspect to retrieve the client | ||
* @return AspectCallbackRoutingClient for the given aspect class, or null if not found | ||
*/ | ||
public <ASPECT extends RecordTemplate> AspectCallbackRoutingClient getAspectCallbackRoutingClient( | ||
@Nonnull Class<ASPECT> aspectClass) { | ||
return aspectCallbackMap.get(aspectClass); | ||
} | ||
|
||
/** | ||
* Check if Aspect Callback Routing Client is registered for an aspect. | ||
*/ | ||
public <ASPECT extends RecordTemplate> boolean isRegistered(@Nonnull final Class<ASPECT> aspectClass) { | ||
return aspectCallbackMap.containsKey(aspectClass); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
dao-api/src/main/java/com/linkedin/metadata/dao/ingestion/AspectCallbackResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.linkedin.metadata.dao.ingestion; | ||
|
||
import com.linkedin.data.template.RecordTemplate; | ||
import lombok.Data; | ||
|
||
/** | ||
* Response of in-update process that includes the updated aspect. It can be extended to include additional information. | ||
*/ | ||
@Data | ||
public class AspectCallbackResponse<ASPECT extends RecordTemplate> { | ||
private final ASPECT updatedAspect; | ||
} |
28 changes: 28 additions & 0 deletions
28
dao-api/src/main/java/com/linkedin/metadata/dao/ingestion/AspectCallbackRoutingClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.linkedin.metadata.dao.ingestion; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.data.template.RecordTemplate; | ||
import java.util.Optional; | ||
|
||
|
||
/** | ||
* An interface that defines the client for aspect callback routing. | ||
*/ | ||
public interface AspectCallbackRoutingClient<ASPECT extends RecordTemplate> { | ||
/** | ||
* A method that routes the updates request to the appropriate custom API. | ||
* @param urn the urn of the asset | ||
* @param newAspectValue the aspect to be updated | ||
* @param existingAspectValue the existing aspect value | ||
* @return AspectCallbackResponse containing the updated aspect | ||
*/ | ||
AspectCallbackResponse<ASPECT> routeAspectCallback(Urn urn, ASPECT newAspectValue, Optional<ASPECT> existingAspectValue); | ||
|
||
/** | ||
* A method that returns whether to skip processing further ingestion. | ||
* @return true if the ingestion should be skipped, false otherwise | ||
*/ | ||
default boolean isSkipProcessing() { | ||
return false; | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
.../src/main/java/com/linkedin/metadata/dao/ingestion/preupdate/PreUpdateAspectRegistry.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
dao-api/src/main/java/com/linkedin/metadata/dao/ingestion/preupdate/PreUpdateResponse.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.