Skip to content

Commit

Permalink
Add support for .env (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
spetz authored Nov 30, 2024
1 parent 456c282 commit 700fe38
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bench_*
/rust-clippy-results.sarif
/Cross.toml
/performance_results*
.env
11 changes: 9 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion bench/src/benchmarks/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub trait Benchmarkable {
fn display_settings(&self);

/// Below methods have common implementation for all benchmarks.
/// Initializes the streams and topics for the benchmark.
/// This method is called before the benchmark is executed.
async fn init_streams(&self) -> Result<(), IggyError> {
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/examples/test_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct TestBasic<'a> {
expected_consumer_output: Vec<&'a str>,
}

impl<'a> IggyExampleTestCase for TestBasic<'a> {
impl IggyExampleTestCase for TestBasic<'_> {
fn verify_log_output(&self, producer_stdout: &str, consumer_stdout: &str) {
verify_stdout_contains_expected_logs(
producer_stdout,
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/examples/test_getting_started.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct TestGettingStarted<'a> {
expected_consumer_output: Vec<&'a str>,
}

impl<'a> IggyExampleTestCase for TestGettingStarted<'a> {
impl IggyExampleTestCase for TestGettingStarted<'_> {
fn verify_log_output(&self, producer_stdout: &str, consumer_stdout: &str) {
verify_stdout_contains_expected_logs(
producer_stdout,
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/examples/test_message_envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct TestMessageEnvelope<'a> {
expected_consumer_output: Vec<&'a str>,
}

impl<'a> IggyExampleTestCase for TestMessageEnvelope<'a> {
impl IggyExampleTestCase for TestMessageEnvelope<'_> {
fn verify_log_output(&self, producer_stdout: &str, consumer_stdout: &str) {
verify_stdout_contains_expected_logs(
producer_stdout,
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/examples/test_message_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct TestMessageHeaders<'a> {
expected_consumer_output: Vec<&'a str>,
}

impl<'a> IggyExampleTestCase for TestMessageHeaders<'a> {
impl IggyExampleTestCase for TestMessageHeaders<'_> {
fn verify_log_output(&self, producer_stdout: &str, consumer_stdout: &str) {
verify_stdout_contains_expected_logs(
producer_stdout,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/compression/compression_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl From<CompressionAlgorithm> for String {
}
struct CompressionKindVisitor;

impl<'de> Visitor<'de> for CompressionKindVisitor {
impl Visitor<'_> for CompressionKindVisitor {
type Value = CompressionAlgorithm;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
10 changes: 8 additions & 2 deletions sdk/src/locking/fast_async_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ impl<T> IggySharedMutFn<T> for IggyFastAsyncRwLock<T>
where
T: Send + Sync,
{
type ReadGuard<'a> = RwLockReadGuard<'a, T> where T: 'a;
type WriteGuard<'a> = RwLockWriteGuard<'a, T> where T: 'a;
type ReadGuard<'a>
= RwLockReadGuard<'a, T>
where
T: 'a;
type WriteGuard<'a>
= RwLockWriteGuard<'a, T>
where
T: 'a;
fn new(data: T) -> Self {
IggyFastAsyncRwLock(Arc::new(FastAsyncRwLock::new(data)))
}
Expand Down
10 changes: 8 additions & 2 deletions sdk/src/locking/tokio_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ impl<T> IggySharedMutFn<T> for IggyTokioRwLock<T>
where
T: Send + Sync,
{
type ReadGuard<'a> = RwLockReadGuard<'a, T> where T: 'a;
type WriteGuard<'a> = RwLockWriteGuard<'a, T> where T: 'a;
type ReadGuard<'a>
= RwLockReadGuard<'a, T>
where
T: 'a;
type WriteGuard<'a>
= RwLockWriteGuard<'a, T>
where
T: 'a;

fn new(data: T) -> Self {
IggyTokioRwLock(Arc::new(TokioRwLock::new(data)))
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/utils/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<'de> Deserialize<'de> for IggyDuration {
}
}

impl<'de> Visitor<'de> for IggyDurationVisitor {
impl Visitor<'_> for IggyDurationVisitor {
type Value = IggyDuration;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/utils/expiry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'de> Deserialize<'de> for IggyExpiry {

struct IggyExpiryVisitor;

impl<'de> Visitor<'de> for IggyExpiryVisitor {
impl Visitor<'_> for IggyExpiryVisitor {
type Value = IggyExpiry;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/utils/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'de> Deserialize<'de> for IggyTimestamp {
}
struct IggyTimestampVisitor;

impl<'de> Visitor<'de> for IggyTimestampVisitor {
impl Visitor<'_> for IggyTimestampVisitor {
type Value = IggyTimestamp;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/utils/topic_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Serialize for MaxTopicSize {

struct MaxTopicSizeVisitor;

impl<'de> Visitor<'de> for MaxTopicSizeVisitor {
impl Visitor<'_> for MaxTopicSizeVisitor {
type Value = MaxTopicSize;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
3 changes: 2 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.4.82"
version = "0.4.83"
edition = "2021"
build = "src/build.rs"

Expand All @@ -25,6 +25,7 @@ clap = { version = "4.5.17", features = ["derive"] }
console-subscriber = { version = "0.4.0", optional = true }
dashmap = "6.0.1"
derive_more = "1.0.0"
dotenvy = { version = "0.15.7" }
figlet-rs = "0.1.5"
figment = { version = "0.10.18", features = ["toml", "env"] }
flume = "0.11.0"
Expand Down
2 changes: 1 addition & 1 deletion server/src/configs/resource_quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl FromStr for MemoryResourceQuota {

struct ResourceQuotaVisitor;

impl<'de> Visitor<'de> for ResourceQuotaVisitor {
impl Visitor<'_> for ResourceQuotaVisitor {
type Value = MemoryResourceQuota;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions server/src/configs/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Validatable<ServerError> for ArchiverConfig {
return Ok(());
}

return match self.kind {
match self.kind {
ArchiverKind::Disk => {
if self.disk.is_none() {
return Err(ServerError::InvalidConfiguration(
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Validatable<ServerError> for ArchiverConfig {
}
Ok(())
}
};
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use clap::Parser;
use dotenvy::dotenv;
use figlet_rs::FIGfont;
use server::args::Args;
use server::channels::commands::archive_state::ArchiveStateExecutor;
Expand Down Expand Up @@ -31,6 +32,13 @@ async fn main() -> Result<(), ServerError> {
let figure = standard_font.convert("Iggy Server");
println!("{}", figure.unwrap());

if let Ok(path) = dotenv() {
println!(
"Loaded environment variables from .env file at path: {}",
path.display()
);
}

let args = Args::parse();
let config_provider = config_provider::resolve(&args.config_provider)?;
let config = ServerConfig::load(config_provider.as_ref()).await?;
Expand Down
2 changes: 1 addition & 1 deletion server/src/streaming/batching/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> RetainedMessageBatchIterator<'a> {

// TODO(numinex): Consider using FallibleIterator instead of this
// https://crates.io/crates/fallible-iterator
impl<'a> Iterator for RetainedMessageBatchIterator<'a> {
impl Iterator for RetainedMessageBatchIterator<'_> {
type Item = RetainedMessage;
fn next(&mut self) -> Option<Self::Item> {
if self.current_position < self.batch.length.as_bytes_u64() {
Expand Down
1 change: 1 addition & 0 deletions server/src/streaming/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod buffer;
#[allow(static_mut_refs)]
pub mod memory_tracker;

0 comments on commit 700fe38

Please sign in to comment.