Page MenuHomePhabricator

[services] Tunnelbroker - Changes to handle HTTP code inside the Rust `send_notif_to_apns` function
AbandonedPublic

Authored by max on Sep 6 2022, 6:36 AM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 26 2024, 2:30 AM
Unknown Object (File)
Oct 25 2024, 11:48 PM
Unknown Object (File)
Oct 19 2024, 1:46 AM
Unknown Object (File)
Oct 19 2024, 1:46 AM
Unknown Object (File)
Oct 19 2024, 1:39 AM
Unknown Object (File)
Sep 1 2024, 10:58 AM
Unknown Object (File)
Sep 1 2024, 10:57 AM
Unknown Object (File)
Sep 1 2024, 10:53 AM

Details

Summary

This diff introduces changes to the send_notif_to_apns function to handle the HTTP error code inside the function instead of passing it to the upper level. Passing to the upper level and handling it in another place and then inside the function doesn't make sense. The better approach here is to handle the errors inside the Rust function and return an Error in case something goes wrong.

Related linear task: ENG-1740

Test Plan
  1. Successfully built using Docker.
  2. Successfully call the function from C++:
#include "cxxbridge_code/src/lib.rs.h"
#include "rust/cxx.h
...
const std::string cert_path = argv[1];
const std::string cert_pass = argv[2];
const std::string device_token = argv[3];
const std::string message_body = argv[4];
sendNotifToAPNS(cert_path, cert_pass, device_token, message_body, true);

Diff Detail

Repository
rCOMM Comm
Branch
void-for-apns
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

max held this revision as a draft.
max edited the test plan for this revision. (Show Details)
max added reviewers: karol, tomek, varun.
max published this revision for review.Sep 6 2022, 6:44 AM
max edited the summary of this revision. (Show Details)
karol added inline comments.
services/tunnelbroker/rust-notifications/src/apns.rs
30

what is the difference between this and bail!?

services/tunnelbroker/rust-notifications/src/lib.rs
17

does anyhow::Result have <(), anyhow::Error> automatically?

jon added inline comments.
services/tunnelbroker/rust-notifications/src/apns.rs
30

This macro is equivalent to return Err(anyhow!($args...)).

They're the same.

https://docs.rs/anyhow/latest/anyhow/macro.bail.html

Abandon due to ENG-1764: Distinguish common and wrong/expired device token errors in Rust notification library.

max added inline comments.
services/tunnelbroker/rust-notifications/src/lib.rs
17

does anyhow::Result have <(), anyhow::Error> automatically?

Yes, it handles it automatically.