-
Notifications
You must be signed in to change notification settings - Fork 24
Feature/background job implementation #300
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
base: master
Are you sure you want to change the base?
Feature/background job implementation #300
Conversation
8c667d0 to
c09cf6d
Compare
| public interface IRepositoryService { | ||
|
|
||
| // CHNG: Remove new pull relation | ||
| String RELATION_PULL_WITHOUT_BG = "http://www.sap.com/adt/abapgit/relations/pullwithoutbg"; //$NON-NLS-1$ |
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.
Change the URI as per backend, pull/v2
| URI backgroundUri = AdtBackgroundRunUriDiscoveryFactory.createBackgroundRunUriDiscovery(this.destinationId) | ||
| .getBackgroundRunUriIfAuthorized(monitor); | ||
| IRestResource restResource = AdtBackgroundRestResourceFactory.createBackgroundRestResourceFactory() |
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.
If the background URI is unsupported, should we provide a fallback to an older resource? While it's unlikely given that we only support cloud systems, this should be verified once.
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.
How can I check whether the URI is supported or not?
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.
We already have a method isBackgroundJobSupported in repository service.
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.
Sure thanks will check it out
| pullRepoJob.schedule(); | ||
|
|
||
| return true; |
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.
Can we somehow trigger a refresh of the view once the job has finished ?
The status is not updated in the viewer after job has completed.
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.
in the AbapGitView I see a updateView(true) after pull action is triggered however I also don't see it actually refreshing once the pull is done. Will check why thats happening
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.
Please check the callback related logic in other comment. What are your thoughts on it.
| // CHNG: Remove new pull relation | ||
| String RELATION_PULL_WITHOUT_BG = "http://www.sap.com/adt/abapgit/relations/pullwithoutbg"; //$NON-NLS-1$ | ||
| String RELATION_PULL = "http://www.sap.com/adt/abapgit/relations/pull"; //$NON-NLS-1$ | ||
| String RELATION_PULL_WITHOUT_BG = "http://www.sap.com/adt/abapgit/relations/pull/v2"; //$NON-NLS-1$ |
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.
Variable name, could be RELATION_PULL_WITH_BG_RUN
|
|
||
| private final String destinationId; | ||
| private final URI uri; | ||
| private String result; |
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.
This variable is not used.
|
|
||
| } | ||
|
|
||
| // CHNG: Change it back to original pull relation |
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.
Remove the comment.
|
|
||
| IRestResource restResource = null; | ||
| URI uriToRepo = null; | ||
| // check if background job framework is available and is accessible by the user. |
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.
Remove comments. The method names should be sufficient.
| } | ||
|
|
||
| public void refreshView() { | ||
| org.eclipse.swt.widgets.Display.getDefault().asyncExec(() -> { |
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.
Import Display API and then use.
| IViewPart view = page.findView(AbapGitView.ID); | ||
| if (view instanceof AbapGitView) { | ||
| ((AbapGitView) view).refresh(); |
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.
This logic needs to find the view from all the active views.
I want to avoid this call.
Hence, looking at some other way to keep stuff decoupled.
So,
- Refresh of a view should be decoupled from the pull wizard.
- Refresh should be part of the action which starts the pull.
- Avoid a central disconnected utility just to refresh UI.
Hence I was looking into a callback mechanism.
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.
In our actionPullWizard implementation, we could first implement a callback as lamba expression.
this.actionPullWizard = new Action() {
private IRepository selRepo;
public void run() {
// Create callback that refreshes the view
Runnable onPullComplete = () -> AbapGitView.this.updateView(true);
and we can send it within the constructor of AbapGitWizardPull and add it as an instance variable.
Then in our finally block of the job, we can run this call back.
} finally {
// Execute callback after job completes
if (AbapGitWizardPull.this.onPullComplete!= null) {
Display.getDefault().asyncExec(AbapGitWizardPull.this.onPullComplete);
}
}
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.
But also this could be over-engineering and we can as well just pass the AbapGit view instance to the wizard and refresh the view.
Given we have the wizards initiated directly from the view, this should be fine as well.
| pullRepoJob.schedule(); | ||
|
|
||
| return true; |
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.
Please check the callback related logic in other comment. What are your thoughts on it.
Push Channel Support for long running jobs:
Backlog link : https://jira.tools.sap/browse/ADTIRA-1494
Changes Made: