Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions omni-relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,31 @@ pub struct Redis {
pub struct Nats {
pub url: String,
pub relayer_subject: String,
pub omni_consumer: NatsConsumer,
pub relayer_consumer: NatsConsumer,
pub omni_consumer: OmniConsumer,
pub relayer_consumer: RelayerConsumer,
}

#[derive(Debug, Clone, Deserialize)]
pub struct NatsConsumer {
pub struct OmniConsumer {
pub name: String,
pub stream: String,
pub subject: String,
pub max_deliver: i64,
#[serde(default)]
pub backoff_secs: Vec<u64>,
#[serde(default = "default_worker_count")]
pub worker_count: usize,
}

#[derive(Debug, Clone, Deserialize)]
pub struct RelayerConsumer {
pub name: String,
pub stream: String,
pub subject: String,
pub max_deliver: i64,
pub ack_wait: u64,
pub max_backoff_hours: u64,
pub max_message_age_hours: u64,
#[serde(default = "default_worker_count")]
pub worker_count: usize,
}

fn default_worker_count() -> usize {
Expand Down
3 changes: 1 addition & 2 deletions omni-relayer/src/utils/nats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ impl NatsClient {
deliver_policy: consumer::DeliverPolicy::Last,
max_deliver: config.omni_consumer.max_deliver,
filter_subject: config.omni_consumer.subject.clone(),
backoff: config
.omni_consumer
backoff: config.omni_consumer
.backoff_secs
.iter()
.map(|&s| Duration::from_secs(s))
Expand Down
2 changes: 1 addition & 1 deletion omni-relayer/src/workers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub enum DeployToken {
async fn handle_nats_ack(
msg: &async_nats::jetstream::message::Message,
result: &Result<EventAction>,
config: &config::NatsConsumer,
config: &config::RelayerConsumer,
) {
let max_backoff = Duration::from_secs(config.max_backoff_hours * 3600);
let max_message_age = Duration::from_secs(config.max_message_age_hours * 3600);
Expand Down
Loading