Skip to content

Commit

Permalink
fix: use flush_period instead of buf_size for important streams (#…
Browse files Browse the repository at this point in the history
…255)

* fix: use timeout instead of buf_size

* fix: `timeout`~>`flush_period`

* fix: default to `MAX_BUF_SIZE` when unconfigured

* fix: use of proper term in example config
  • Loading branch information
de-sh authored Jul 15, 2023
1 parent c40304b commit 3ee408b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions configs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ blacklist = ["cancollector_metrics", "candump_metrics", "pinger"]
# it as non-persistent. streams are internally constructed as a map of Name -> Config
[streams.device_shadow]
topic = "/tenants/{tenant_id}/devices/{device_id}/events/device_shadow/jsonarray"
buf_size = 1
flush_period = 5

# Example using compression
[streams.imu]
Expand Down Expand Up @@ -119,7 +119,7 @@ persistence = { max_file_count = 3 }
# This also means that we require a topic to be configured or uplink will error out.
[action_status]
topic = "/tenants/{tenant_id}/devices/{device_id}/action/status"
buf_size = 1
flush_period = 2

# Configurations for uplink's built-in file downloader, including the actions that can trigger
# a download, the location in file system where uplink will download and store files from the
Expand Down
6 changes: 6 additions & 0 deletions uplink/src/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ fn default_timeout() -> u64 {
DEFAULT_TIMEOUT
}

#[inline]
fn max_buf_size() -> usize {
MAX_BUFFER_SIZE
}

fn default_file_size() -> usize {
10485760 // 10MB
}
Expand All @@ -46,6 +51,7 @@ pub enum Compression {
#[derive(Debug, Clone, Deserialize)]
pub struct StreamConfig {
pub topic: String,
#[serde(default = "max_buf_size")]
pub buf_size: usize,
#[serde(default = "default_timeout")]
/// Duration(in seconds) that bridge collector waits from
Expand Down
5 changes: 2 additions & 3 deletions uplink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ pub mod config {
[action_status]
topic = "/tenants/{tenant_id}/devices/{device_id}/action/status"
buf_size = 1
timeout = 10
flush_period = 2
[streams.device_shadow]
topic = "/tenants/{tenant_id}/devices/{device_id}/events/device_shadow/jsonarray"
buf_size = 1
flush_period = 5
[streams.logs]
topic = "/tenants/{tenant_id}/devices/{device_id}/events/logs/jsonarray"
Expand Down

0 comments on commit 3ee408b

Please sign in to comment.