@@ -44,7 +44,7 @@ pub struct MailboxWorkerConfig {
4444impl Default for MailboxWorkerConfig {
4545 fn default ( ) -> Self {
4646 Self {
47- concurrency_limit : 50 ,
47+ concurrency_limit : 250 ,
4848 scan_interval : Duration :: from_secs ( 15 ) ,
4949 batch_size : 100 ,
5050 base_retry_delay : Duration :: from_secs ( 5 ) ,
@@ -56,6 +56,77 @@ impl Default for MailboxWorkerConfig {
5656 }
5757}
5858
59+ impl MailboxWorkerConfig {
60+ pub fn from_env ( ) -> Self {
61+ let default = Self :: default ( ) ;
62+ Self {
63+ concurrency_limit : env_usize (
64+ "MAILBOX_WORKER_CONCURRENCY_LIMIT" ,
65+ default. concurrency_limit ,
66+ ) ,
67+ scan_interval : env_duration_secs (
68+ "MAILBOX_WORKER_SCAN_INTERVAL_SECS" ,
69+ default. scan_interval ,
70+ ) ,
71+ batch_size : env_i64 ( "MAILBOX_WORKER_BATCH_SIZE" , default. batch_size ) ,
72+ base_retry_delay : env_duration_secs (
73+ "MAILBOX_WORKER_BASE_RETRY_DELAY_SECS" ,
74+ default. base_retry_delay ,
75+ ) ,
76+ max_retry_delay : env_duration_secs (
77+ "MAILBOX_WORKER_MAX_RETRY_DELAY_SECS" ,
78+ default. max_retry_delay ,
79+ ) ,
80+ claim_ttl : env_duration_secs ( "MAILBOX_WORKER_CLAIM_TTL_SECS" , default. claim_ttl ) ,
81+ claim_renew_interval : env_duration_secs (
82+ "MAILBOX_WORKER_CLAIM_RENEW_INTERVAL_SECS" ,
83+ default. claim_renew_interval ,
84+ ) ,
85+ stream_idle_reconnect : env_duration_secs (
86+ "MAILBOX_WORKER_STREAM_IDLE_RECONNECT_SECS" ,
87+ default. stream_idle_reconnect ,
88+ ) ,
89+ }
90+ }
91+
92+ pub fn log ( & self ) {
93+ tracing:: info!(
94+ service = "mailbox_worker" ,
95+ concurrency_limit = self . concurrency_limit,
96+ scan_interval_secs = self . scan_interval. as_secs( ) ,
97+ batch_size = self . batch_size,
98+ base_retry_delay_secs = self . base_retry_delay. as_secs( ) ,
99+ max_retry_delay_secs = self . max_retry_delay. as_secs( ) ,
100+ claim_ttl_secs = self . claim_ttl. as_secs( ) ,
101+ claim_renew_interval_secs = self . claim_renew_interval. as_secs( ) ,
102+ stream_idle_reconnect_secs = self . stream_idle_reconnect. as_secs( ) ,
103+ "mailbox worker config loaded"
104+ ) ;
105+ }
106+ }
107+
108+ fn env_usize ( key : & str , default : usize ) -> usize {
109+ std:: env:: var ( key)
110+ . ok ( )
111+ . and_then ( |value| value. parse ( ) . ok ( ) )
112+ . unwrap_or ( default)
113+ }
114+
115+ fn env_i64 ( key : & str , default : i64 ) -> i64 {
116+ std:: env:: var ( key)
117+ . ok ( )
118+ . and_then ( |value| value. parse ( ) . ok ( ) )
119+ . unwrap_or ( default)
120+ }
121+
122+ fn env_duration_secs ( key : & str , default : Duration ) -> Duration {
123+ std:: env:: var ( key)
124+ . ok ( )
125+ . and_then ( |value| value. parse ( ) . ok ( ) )
126+ . map ( Duration :: from_secs)
127+ . unwrap_or ( default)
128+ }
129+
59130#[ derive( Debug , Clone ) ]
60131pub struct MailboxSessionContext {
61132 pub worker_id : String ,
@@ -436,7 +507,7 @@ impl MailboxTransport for Beta8MailboxTransport {
436507 Err ( status) => return Ok ( map_tonic_status ( status) ) ,
437508 } ;
438509
439- tracing:: info !(
510+ tracing:: trace !(
440511 service = "mailbox_worker" ,
441512 pubkey = %mailbox. pubkey,
442513 checkpoint,
@@ -459,7 +530,7 @@ impl MailboxTransport for Beta8MailboxTransport {
459530 }
460531 }
461532 _ = & mut idle_reconnect => {
462- tracing:: debug !(
533+ tracing:: trace !(
463534 service = "mailbox_worker" ,
464535 pubkey = %mailbox. pubkey,
465536 checkpoint,
0 commit comments