-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added RPC invocation for PreUpdate #443
Changes from 10 commits
ae7df55
1745064
c4b8eb9
de677eb
e687357
cf5391f
aa5cdcc
a48088b
18e534b
54044a3
86de865
8b5abca
a40bd9f
232f1dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.linkedin.metadata.dao.ingestion.preupdate; | ||
|
||
import com.linkedin.data.template.RecordTemplate; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import javax.annotation.Nonnull; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
/** | ||
* A registry which maintains mapping of aspects and their GrpcPreUpdateRoutingClient. | ||
*/ | ||
@Slf4j | ||
public class GrpcPreUpdateRegistry<ASPECT extends RecordTemplate> { | ||
|
||
private Map<Class<? extends RecordTemplate>, RoutingMap> _preUpdateLambdaMap = | ||
new ConcurrentHashMap<>(); | ||
|
||
/** | ||
* Get GrpcPreUpdateRoutingClient for an aspect. | ||
*/ | ||
public RoutingMap getPreUpdateRoutingClient(@Nonnull final ASPECT aspect){ | ||
return _preUpdateLambdaMap.get(aspect.getClass()); | ||
} | ||
|
||
/** | ||
* Check if GrpcPreUpdateRoutingClient is registered for an aspect. | ||
*/ | ||
public boolean isRegistered(@Nonnull final Class<ASPECT> aspectClass){ | ||
return _preUpdateLambdaMap.containsKey(aspectClass); | ||
} | ||
|
||
/** | ||
* Register a pre update lambda for the given aspect | ||
* @param aspectClass aspect class | ||
* @param preUpdateRoutingMap pre update routing map | ||
*/ | ||
public void registerPreUpdateLambda(@Nonnull Class<? extends RecordTemplate> aspectClass, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, who should register this lambda? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can create a Factory
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's include all those detail in your doc and trying to see which part can be covered by SMO in the future |
||
@Nonnull RoutingMap preUpdateRoutingMap) { | ||
log.info("Registering pre update lambda: {}, {}", aspectClass.getCanonicalName(), preUpdateRoutingMap); | ||
_preUpdateLambdaMap.put(aspectClass, preUpdateRoutingMap); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.linkedin.metadata.dao.ingestion.preupdate; | ||
|
||
import com.google.protobuf.Message; | ||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.data.template.RecordTemplate; | ||
|
||
|
||
public interface PreUpdateClient<ASPECT extends Message> { | ||
|
||
/** | ||
* Executes the gRPC pre-update logic, including building the request, | ||
* invoking the service, and handling the response. | ||
* | ||
* @param urn The URN of the entity to be updated. | ||
* @param aspect The aspect to be updated. | ||
* @return The updated aspect. | ||
*/ | ||
PreUpdateResponse<ASPECT> preUpdate(Message urn, ASPECT aspect); | ||
|
||
/** | ||
* Converts a RecordTemplate URN to a gRPC-compatible Message. | ||
* | ||
* @param urn The RecordTemplate URN. | ||
* @return The gRPC-compatible Message URN. | ||
*/ | ||
Message convertUrnToMessage(Urn urn); | ||
|
||
/** | ||
* Converts a RecordTemplate Aspect to a gRPC-compatible Message Aspect. | ||
* | ||
* @param aspect The RecordTemplate aspect. | ||
* @return The gRPC-compatible Message aspect. | ||
*/ | ||
ASPECT convertAspectToMessage(RecordTemplate aspect); | ||
|
||
/** | ||
* Converts a gRPC-compatible Message Aspect back to a RecordTemplate Aspect. | ||
* | ||
* @param messageAspect The Message aspect. | ||
* @return The RecordTemplate aspect. | ||
*/ | ||
RecordTemplate convertAspectToRecordTemplate(ASPECT messageAspect); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.linkedin.metadata.dao.ingestion.preupdate; | ||
|
||
import com.google.protobuf.Message; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class PreUpdateResponse<ASPECT extends Message> { | ||
private final ASPECT updatedAspect; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.linkedin.metadata.dao.ingestion.preupdate; | ||
|
||
import com.google.protobuf.Message; | ||
import lombok.Data; | ||
|
||
|
||
@Data | ||
public class RoutingMap { | ||
|
||
public enum RoutingAction { | ||
SKIP, | ||
PROCEED | ||
} | ||
public PreUpdateClient<? extends Message> preUpdateClient; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we call this method? Should we do it through inject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we will inject it in the AssetClass where we call the ingestion method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For RestliRegistry, I was setting it in DatasetLocalDao.