-
Notifications
You must be signed in to change notification settings - Fork 16
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
PIR Stabilization: Extract Operation Building from Processor #2743
PIR Stabilization: Extract Operation Building from Processor #2743
Conversation
CC @Bunn - this is the PR we chatted about on MM. |
|
||
typealias OperationType = DataBrokerOperation.OperationType | ||
|
||
protocol DataBrokerOperationsBuilder { |
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.
Some feedback here re: naming of Builder
. I don’t feel too strongly, but will wait for any more input here from reviewers before making any changes.
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.
I also have little opinion on it, except for avoiding initializer since it's obviously a thing already
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.
Renamed to DataBrokerOperationsCreator
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.
Massive props for seperating out different commits, it makes it much easier to review!
|
||
typealias OperationType = DataBrokerOperation.OperationType | ||
|
||
protocol DataBrokerOperationsBuilder { |
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.
I also have little opinion on it, except for avoiding initializer since it's obviously a thing already
func operations(operationType: OperationType, | ||
priorityDate: Date?, | ||
showWebView: Bool, | ||
operationDependencies: OperationDependencies) throws -> [DataBrokerOperationsCollection] { |
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.
I can't quite come up with anything I'm completely happy with, but it would be good to distinguish between the types of parameters here (a/ things that dictate the type of operations returned and b/ things the operations depend on), how about:
func operations(forOperationType operationType: OperationType,
withPriorityDate priorityDate: Date?,
showWebView: Bool,
operationDependencies: OperationDependencies) throws -> [DataBrokerOperationsCollection]
Although if you accused me of never getting over Objective-C from this suggestion it would be hard to rebuke
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.
Nice idea (even if influenced by Obj-C 😄). I’ll make the suggested changes.
@@ -146,7 +136,6 @@ final class DataBrokerOperation: Operation { | |||
allBrokerProfileQueryData = try database.fetchAllBrokerProfileQueryData() | |||
} catch { | |||
os_log("DataBrokerOperationsCollection error: runOperation, error: %{public}@", log: .error, error.localizedDescription) | |||
errorDelegate?.dataBrokerOperation(self, didErrorBeforeStartingBrokerOperations: error) |
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.
What's the plan for error propagation?
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.
Good question! My initial thinking here was:
- We are currently not utilizing the error propagation (we were simply firing a pixel, while also injecting the pixel handler into
DataBrokerOperation
. So I just changed to fire the pixel directly in theDataBrokerOperation
. - Based on above, I didn’t want to carry-over code from the old implementation if there was no explicit use for it.
- I considered error propagation, and decided that not including it right now (as we don’t use it), while also refactoring in a way that it’s easy to add later, was the way to go.
- However , saying all that, I think we can conclusively say that we do want error propagation as some point, and so it’s not an over-optimization. As such, I can re-add it, and we can decide how to use it later.
Edit: After looking more at the code, and thinking about this, I don’t think we should propagate at the moment. This is because we also ‘handle’ errors in the barrier block of the processor. As follows:
operationQueue.addBarrierBlock {
let operationErrors = operations.compactMap { $0.error }
let errorCollection = operationErrors.count != 0 ? DataBrokerProtectionSchedulerErrorCollection(operationErrors: operationErrors) : nil
completion(errorCollection)
}
Not sure this is what we want, but until we know it isn’t, I don’t think we need an explicit propagation from individual operations.
What do you think?
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.
I think we at least need a plan for it, do you have any ideas on what the best way to add it would be? It might be easier to reason about in the context of the next PR
I think we do need to make sure if the function is interrupted it still returns scan errors correctly
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.
Cool, yup, agree that we need to ensure that interrupted operation queues should still return errors, and also that this will be easier to reason about with the subsequent ‘QueueManager’ work. I’ll fix Swiftlint errors and merge this.
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.
LGTM!
bab2f29
to
1452cc5
Compare
LGTM, just note that the failing tests are failing for an actual reason:
Please take a look at this before merging |
Task/Issue URL: https://app.asana.com/0/1199230911884351/1207338264132623/f Tech Design URL: https://app.asana.com/0/481882893211075/1207174884557414/f CC: **Description**: This PR has the effect of mergeing four different PRs into main: #2777 #2758 #2757 #2743 This covers significant changes to the XPC interface and how the main app uses it, the background manager, the scheduler, and the processor. See individual PRs for details. There's no code changes here that haven't been reviewed separately as part of those PRs, so it's up to you how you want to review it code wise. The more important step at this stage is manual testing. **Steps to test this PR**: 1. Because this is a fairly significant set of changes, we need to be as thorough as we can in testing DBP generally works and really try to break it. Because of this, I'm keen that anyone testing things of their own ways to break it before trying the steps below. 2. Edit/add profile data, and before scans finish, edit it again. Scans should start afresh, and you should see an interrupted pixel fire. Check that you don't get a scans completed notification 3. Edit/add profile data, and before scans finish, close the app, and reopen it. The same set of manual scans should still continue, and a blocked pixel should fire. 4. With profile data already existing but initial scans having finished, close the app and reopen it. Scheduled scans should run. 5. With profile data already existing, and with the app closed, launch the background agent, scheduled scans should run 6. Edit/add profile data, put the laptop to sleep/lock it/restart it, check that scans continue as expected. 7. Check that the background agent activity lines up with the UI, I.e. the progress bar and when we sent the scans completed notification is accurate <!-- Tagging instructions If this PR isn't ready to be merged for whatever reason it should be marked with the `DO NOT MERGE` label (particularly if it's a draft) If it's pending Product Review/PFR, please add the `Pending Product Review` label. If at any point it isn't actively being worked on/ready for review/otherwise moving forward (besides the above PR/PFR exception) strongly consider closing it (or not opening it in the first place). If you decide not to close it, make sure it's labelled to make it clear the PRs state and comment with more information. --> --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) --------- Co-authored-by: Pete Smith <[email protected]>
Task/Issue URL: https://app.asana.com/0/1199230911884351/1207175016813446/f
Tech Design URL: https://app.asana.com/0/0/1207199754528648/f
CC:
Description:
This PR includes all changes relating to this tech design sub-task. Specifically:
DataBrokerOperationsCollection
building to a dedicated type, and adds testsDataBrokerOperationsBuilder
to build operations in the ‘Processor'DataBrokerOperationsCollection
toDataBrokerOperation
DataBrokerOperation
toDataBrokerJob
, and renames related typesBrokerOperationData
and related types toBrokerJobData
Note: There is a lot of renaming changes in this PR. To mitigate this, the renaming changes are all grouped in dedicated commits. Therefore, to review this PR, it’s best to review commit-by-commit. This way you can focus on the commits which are not purely renaming-related.
Steps to test this PR:
—
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation