Skip to content

Commit db24433

Browse files
author
chaodu-agent
committed
fix: add AppState and related types to gateway lib.rs
These were previously in gateway/src/main.rs and accessed by adapters via crate::AppState. Now that gateway is a library crate, they need to be in lib.rs for the adapters to compile.
1 parent 585829d commit db24433

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

  • crates/openab-gateway/src

crates/openab-gateway/src/lib.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,46 @@ pub mod adapters;
22
pub(crate) mod media;
33
pub mod schema;
44
pub mod store;
5+
6+
use std::collections::HashMap;
7+
use std::sync::Arc;
8+
use std::time::Instant;
9+
use tokio::sync::{broadcast, Mutex, Semaphore};
10+
11+
// --- Reply token cache for LINE hybrid Reply/Push dispatch ---
12+
13+
/// Cache entry for LINE reply tokens: (replyToken, insertion_time).
14+
pub type ReplyTokenCache = Arc<std::sync::Mutex<HashMap<String, (String, Instant)>>>;
15+
16+
/// Maximum age (in seconds) before a cached reply token is considered expired.
17+
pub const REPLY_TOKEN_TTL_SECS: u64 = 50;
18+
19+
/// Maximum number of cached reply tokens.
20+
pub const REPLY_TOKEN_CACHE_MAX: usize = 10_000;
21+
22+
/// Maximum number of post-ack LINE webhook payloads processed concurrently.
23+
pub const LINE_WEBHOOK_CONCURRENCY_MAX: usize = 8;
24+
25+
// --- App state (shared across all adapters) ---
26+
27+
pub struct AppState {
28+
pub telegram_bot_token: Option<String>,
29+
pub telegram_secret_token: Option<String>,
30+
pub telegram_rich_messages: bool,
31+
pub line_channel_secret: Option<String>,
32+
pub line_access_token: Option<String>,
33+
#[cfg(feature = "teams")]
34+
pub teams: Option<adapters::teams::TeamsAdapter>,
35+
pub teams_service_urls: Mutex<HashMap<String, (String, Instant)>>,
36+
#[cfg(feature = "feishu")]
37+
pub feishu: Option<adapters::feishu::FeishuAdapter>,
38+
#[cfg(feature = "googlechat")]
39+
pub google_chat: Option<adapters::googlechat::GoogleChatAdapter>,
40+
#[cfg(feature = "wecom")]
41+
pub wecom: Option<adapters::wecom::WecomAdapter>,
42+
pub ws_token: Option<String>,
43+
pub event_tx: broadcast::Sender<String>,
44+
pub reply_token_cache: ReplyTokenCache,
45+
pub line_webhook_semaphore: Arc<Semaphore>,
46+
pub client: reqwest::Client,
47+
}

0 commit comments

Comments
 (0)