Skip to content

Commit 812e335

Browse files
committed
remove old capnp code
1 parent 6eae0e6 commit 812e335

File tree

11 files changed

+23
-899
lines changed

11 files changed

+23
-899
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ntfy-daemon/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ capnpc = "0.17.2"
1212
[dependencies]
1313
serde = { version = "1.0", features = ["derive"] }
1414
serde_json = "1.0"
15-
capnp = "0.18.0"
16-
capnp-rpc = "0.18.0"
1715
futures = "0.3.0"
1816
tokio = { version = "1.0.0", features = ["net", "rt", "macros", "parking_lot"]}
1917
tokio-util = { version = "0.7.4", features = ["compat", "io"] }

ntfy-daemon/build.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

ntfy-daemon/src/credentials.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ impl Credentials {
166166
let values = self
167167
.keyring
168168
.search_items(attrs)
169-
.await
170-
.map_err(|e| capnp::Error::failed(e.to_string()))?;
169+
.await?;
171170

172171
let mut lock = self.creds.write().unwrap();
173172
lock.clear();
@@ -206,8 +205,7 @@ impl Credentials {
206205
]);
207206
self.keyring
208207
.create_item("Password", attrs, password, true)
209-
.await
210-
.map_err(|e| capnp::Error::failed(e.to_string()))?;
208+
.await?;
211209

212210
self.creds.write().unwrap().insert(
213211
server.to_string(),
@@ -234,8 +232,7 @@ impl Credentials {
234232
]);
235233
self.keyring
236234
.delete(attrs)
237-
.await
238-
.map_err(|e| capnp::Error::failed(e.to_string()))?;
235+
.await?;
239236
self.creds
240237
.write()
241238
.unwrap()

ntfy-daemon/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ pub mod credentials;
22
pub mod message_repo;
33
pub mod models;
44
pub mod retry;
5-
pub mod system_client;
6-
pub mod topic_listener;
75
mod http_client;
86
mod output_tracker;
97
mod listener;
@@ -14,11 +12,6 @@ pub use subscription::SubscriptionHandle;
1412
pub use listener::*;
1513
pub use ntfy::NtfyHandle;
1614
pub use ntfy::start;
17-
18-
pub mod ntfy_capnp {
19-
include!(concat!(env!("OUT_DIR"), "/src/ntfy_capnp.rs"));
20-
}
21-
2215
use std::sync::Arc;
2316

2417
use http_client::HttpClient;
@@ -51,8 +44,3 @@ pub enum Error {
5144
SubscriptionNotFound(String),
5245
}
5346

54-
impl From<Error> for capnp::Error {
55-
fn from(value: Error) -> Self {
56-
capnp::Error::failed(format!("{:?}", value))
57-
}
58-
}

ntfy-daemon/src/ntfy.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@ use crate::{
1313
http_client::HttpClient,
1414
message_repo::Db,
1515
models::{self, Account},
16-
topic_listener::build_client,
1716
ListenerActor, ListenerCommand, ListenerConfig, ListenerHandle, SharedEnv, SubscriptionHandle,
1817
};
1918

19+
20+
const CONNECT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(15);
21+
const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(240); // 4 minutes
22+
23+
24+
pub fn build_client() -> anyhow::Result<reqwest::Client> {
25+
Ok(reqwest::Client::builder()
26+
.connect_timeout(CONNECT_TIMEOUT)
27+
.pool_idle_timeout(TIMEOUT)
28+
// rustls is used because HTTP 2 isn't discovered with native-tls.
29+
// HTTP 2 is required to multiplex multiple requests over a single connection.
30+
// You can check that the app is using a single connection to a server by doing
31+
// ```
32+
// ping ntfy.sh # to get the ip address
33+
// netstat | grep $ip
34+
// ```
35+
.use_rustls_tls()
36+
.build()?)
37+
}
38+
2039
// Message types for the actor
2140
#[derive()]
2241
pub enum NtfyMessage {

0 commit comments

Comments
 (0)