diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-24 08:02:12 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-24 11:54:18 +0000 |
| commit | 70d0197e85ae4ef85202781f6d2dc9e76bd508b3 (patch) | |
| tree | 45efb6565e81ba755acc5955e68d5b7119d1e122 /src/http | |
| parent | f8c3e3920ed2a1bdaab30be912276993449a5476 (diff) | |
feat(purgatory): add broken purgatory implementation
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index 91a6067..d62cc4a 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs | |||
| @@ -27,6 +27,7 @@ use crate::config::Config; | |||
| 27 | use crate::git; | 27 | use crate::git; |
| 28 | use crate::metrics::Metrics; | 28 | use crate::metrics::Metrics; |
| 29 | use crate::nostr::builder::SharedDatabase; | 29 | use crate::nostr::builder::SharedDatabase; |
| 30 | use crate::purgatory::Purgatory; | ||
| 30 | 31 | ||
| 31 | /// CORS headers required by GRASP-01 specification (lines 40-47) | 32 | /// CORS headers required by GRASP-01 specification (lines 40-47) |
| 32 | const CORS_ALLOW_ORIGIN: &str = "*"; | 33 | const CORS_ALLOW_ORIGIN: &str = "*"; |
| @@ -94,6 +95,8 @@ struct HttpService { | |||
| 94 | database: SharedDatabase, | 95 | database: SharedDatabase, |
| 95 | /// Optional metrics for Prometheus endpoint | 96 | /// Optional metrics for Prometheus endpoint |
| 96 | metrics: Option<Arc<Metrics>>, | 97 | metrics: Option<Arc<Metrics>>, |
| 98 | /// Purgatory for event/git coordination | ||
| 99 | purgatory: Arc<Purgatory>, | ||
| 97 | } | 100 | } |
| 98 | 101 | ||
| 99 | impl HttpService { | 102 | impl HttpService { |
| @@ -103,6 +106,7 @@ impl HttpService { | |||
| 103 | remote: SocketAddr, | 106 | remote: SocketAddr, |
| 104 | database: SharedDatabase, | 107 | database: SharedDatabase, |
| 105 | metrics: Option<Arc<Metrics>>, | 108 | metrics: Option<Arc<Metrics>>, |
| 109 | purgatory: Arc<Purgatory>, | ||
| 106 | ) -> Self { | 110 | ) -> Self { |
| 107 | Self { | 111 | Self { |
| 108 | relay, | 112 | relay, |
| @@ -110,6 +114,7 @@ impl HttpService { | |||
| 110 | remote, | 114 | remote, |
| 111 | database, | 115 | database, |
| 112 | metrics, | 116 | metrics, |
| 117 | purgatory, | ||
| 113 | } | 118 | } |
| 114 | } | 119 | } |
| 115 | } | 120 | } |
| @@ -126,6 +131,7 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 126 | let method = req.method().clone(); | 131 | let method = req.method().clone(); |
| 127 | let git_data_path = self.config.effective_git_data_path(); | 132 | let git_data_path = self.config.effective_git_data_path(); |
| 128 | let database = self.database.clone(); | 133 | let database = self.database.clone(); |
| 134 | let purgatory = self.purgatory.clone(); | ||
| 129 | 135 | ||
| 130 | // Handle OPTIONS preflight requests (CORS) | 136 | // Handle OPTIONS preflight requests (CORS) |
| 131 | // GRASP-01 spec line 47: Respond to OPTIONS with 204 No Content | 137 | // GRASP-01 spec line 47: Respond to OPTIONS with 204 No Content |
| @@ -225,9 +231,10 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 225 | let result = git::handlers::handle_receive_pack( | 231 | let result = git::handlers::handle_receive_pack( |
| 226 | repo_path, | 232 | repo_path, |
| 227 | body_bytes.clone(), | 233 | body_bytes.clone(), |
| 228 | Some(database.clone()), | 234 | database.clone(), |
| 229 | &identifier, | 235 | &identifier, |
| 230 | &owner_pubkey_hex, | 236 | &owner_pubkey_hex, |
| 237 | purgatory.clone(), | ||
| 231 | ) | 238 | ) |
| 232 | .await; | 239 | .await; |
| 233 | 240 | ||
| @@ -497,6 +504,7 @@ pub async fn run_server( | |||
| 497 | relay: LocalRelay, | 504 | relay: LocalRelay, |
| 498 | database: SharedDatabase, | 505 | database: SharedDatabase, |
| 499 | metrics: Option<Arc<Metrics>>, | 506 | metrics: Option<Arc<Metrics>>, |
| 507 | purgatory: Arc<Purgatory>, | ||
| 500 | ) -> anyhow::Result<()> { | 508 | ) -> anyhow::Result<()> { |
| 501 | let bind_addr: SocketAddr = config.bind_address.parse()?; | 509 | let bind_addr: SocketAddr = config.bind_address.parse()?; |
| 502 | 510 | ||
| @@ -515,6 +523,7 @@ pub async fn run_server( | |||
| 515 | addr, | 523 | addr, |
| 516 | database.clone(), | 524 | database.clone(), |
| 517 | metrics.clone(), | 525 | metrics.clone(), |
| 526 | purgatory.clone(), | ||
| 518 | ); | 527 | ); |
| 519 | 528 | ||
| 520 | tokio::spawn(async move { | 529 | tokio::spawn(async move { |