switchgear_pingora/
lib.rs1pub mod backoff;
2pub mod balance;
3pub mod discovery;
4pub mod error;
5pub mod health;
6pub mod pool;
7
8use ::backoff::backoff::Backoff;
9use async_trait::async_trait;
10use std::collections::BTreeSet;
11use std::error::Error;
12use switchgear_service_api::discovery::{DiscoveryBackend, DiscoveryBackends};
13use switchgear_service_api::offer::Offer;
14use switchgear_service_api::service::HasServiceErrorSource;
15
16#[derive(Debug, Clone)]
17pub struct PingoraLnBackendExtension {
18 pub partitions: BTreeSet<String>,
19}
20
21#[async_trait]
22pub trait PingoraBackendProvider {
23 async fn backends(&self, etag: Option<u64>)
24 -> Result<DiscoveryBackends, pingora_error::BError>;
25}
26
27#[async_trait]
28pub trait PingoraLnClientPool {
29 type Error: Error + Send + Sync + 'static + HasServiceErrorSource;
30 type Key: std::hash::Hash + Eq + Send + Sync + 'static;
31
32 async fn get_invoice(
33 &self,
34 offer: &Offer,
35 key: &Self::Key,
36 amount_msat: Option<u64>,
37 expiry_secs: Option<u64>,
38 ) -> Result<String, Self::Error>;
39
40 async fn get_metrics(&self, key: &Self::Key) -> Result<PingoraLnMetrics, Self::Error>;
41
42 fn connect(&self, key: Self::Key, backend: &DiscoveryBackend) -> Result<(), Self::Error>;
43}
44
45pub trait PingoraLnMetricsCache {
46 type Key: std::hash::Hash + Eq;
47
48 fn get_cached_metrics(&self, key: &Self::Key) -> Option<PingoraLnMetrics>;
49}
50
51#[derive(Eq, PartialEq, Debug, Clone, Ord, PartialOrd)]
52pub struct PingoraLnMetrics {
53 pub healthy: bool,
54 pub node_effective_inbound_msat: u64,
55}
56
57pub trait PingoraBackoffProvider: Clone + Send + Sync {
58 type Item: Backoff + Send;
59
60 fn get_backoff(&self) -> Self::Item;
61}