Open Bug 1982671 Opened 2 months ago Updated 2 days ago

[ews] Eliminate required boilerplate for EWS client operations

Categories

(MailNews Core :: Networking: Exchange, task)

Tracking

(Not tracked)

ASSIGNED
145 Branch

People

(Reporter: edicharry, Assigned: jtracey)

References

Details

(Keywords: leave-open)

Attachments

(16 files, 1 obsolete file)

13.71 KB, patch
Details | Diff | Splinter Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Currently, all of our EWS operations have the following structure:

impl XpComEwsClient {

fn some_operation(...) {
    match self.some_operation_inner(...).await {
        Ok(some_data) => //operation success callback,
       Err(err) => //operation failure callback,
    }
}

fn some_operation_inner(...) -> Result<SomeData, XpComEwsError> {

    // construct input, call self.make_operation_request, parse response

}

}

The structure is there to allow the implementation to propagate errors, but the outer function is almost exactly the same for all of the client operations, so we want to eliminate the boiler plate and have a uniform way of doing this.

I'm attaching a partial patch of some work I did as part of another issue that we decided to hold off on in order come up with a more uniform approach for this.

Depends on: 1983596

The new trait is demonstrated with XpComEwsClient::check_connectivity.

Attachment #9507243 - Attachment is obsolete: true

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/152dfd0cefbc
Use operation name constants instead of magic strings. r=edicharry

Status: NEW → ASSIGNED
Target Milestone: --- → 145 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/4613f65ed3f0
Add DoOperation trait to represent doing EWS operations. r=edicharry

Flags: needinfo?(jtracey)

Whoops, didn't properly test the individual patches after rebasing, sorry. New try run for just the one patch: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=bc4e042c4ba99852f351701e40618c3ea3d15dc5

Flags: needinfo?(jtracey)

Pushed by vineet@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/b7ed54290558
Add DoOperation trait to represent doing EWS operations. r=edicharry

Pushed by edicharry@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/7dd560b32fe1
Implement DoOperation for CreateFolder. r=edicharry
https://hg.mozilla.org/comm-central/rev/a243076046cf
Implement DoOperation for copy/move operations. r=edicharry
https://hg.mozilla.org/comm-central/rev/cff0d8f078f3
Implement DoOperation for MarkAsJunk. r=edicharry
https://hg.mozilla.org/comm-central/rev/4094ebeab7d0
Implement DoOperation for SyncFolderHierarchy. r=edicharry
https://hg.mozilla.org/comm-central/rev/a9b5793e18d7
Implement DoOperation for sync_messages_for_folder. r=edicharry
https://hg.mozilla.org/comm-central/rev/26550588c2d3
Implement DoOperation for GetMessage. r=edicharry
https://hg.mozilla.org/comm-central/rev/9faae0b6e51b
Implement DoOperation for SendMessage. r=edicharry
https://hg.mozilla.org/comm-central/rev/f226b3d7daa5
Implement DoOperation for create_message. r=edicharry
https://hg.mozilla.org/comm-central/rev/8407475896ee
Implement DoOperation for delete_messages. r=edicharry
https://hg.mozilla.org/comm-central/rev/fe0803ad0e93
Implement DoOperation for DeleteFolder. r=edicharry
https://hg.mozilla.org/comm-central/rev/1cb3aaa42454
Implement DoOperation for UpdateFolder. r=edicharry

Pushed by vineet@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/f607e3556a50
Implement DoOperation for change_read_status. r=babolivier

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: