Skip to content

Commit

Permalink
Make logrotate_fs a generator
Browse files Browse the repository at this point in the history
This commit migrates logrotate_fs to be a generator and not a stand-alone
binary. While I think it is interesting to consider logrotate_fs as a
user defined generator that's more of a rig that needs to be developed than
I would like to for this project.

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt committed Oct 26, 2024
1 parent de63c23 commit 677d49a
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 212 deletions.
13 changes: 12 additions & 1 deletion lading/src/generator/file_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//!

pub mod logrotate;
pub mod model;
pub mod logrotate_fs;
pub mod traditional;

use std::str;
Expand All @@ -31,6 +31,9 @@ pub enum Error {
/// Wrapper around [`logrotate::Error`].
#[error(transparent)]
Logrotate(#[from] logrotate::Error),
/// Wrapper around [`logrotate_fs::Error`].
#[error(transparent)]
LogrotateFs(#[from] logrotate_fs::Error),
}

/// Configuration of [`FileGen`]
Expand All @@ -42,6 +45,8 @@ pub enum Config {
Traditional(traditional::Config),
/// See [`logrotate::Config`].
Logrotate(logrotate::Config),
/// See [`logrotate_fs::Config`].
LogrotateFs(logrotate_fs::Config),
}

#[derive(Debug)]
Expand All @@ -54,6 +59,8 @@ pub enum FileGen {
Traditional(traditional::Server),
/// See [`logrotate::Server`] for details.
Logrotate(logrotate::Server),
/// See [`logrotate_fs::Server`] for details.
LogrotateFs(logrotate_fs::Server),
}

impl FileGen {
Expand All @@ -78,6 +85,9 @@ impl FileGen {
Self::Traditional(traditional::Server::new(general, c, shutdown)?)
}
Config::Logrotate(c) => Self::Logrotate(logrotate::Server::new(general, c, shutdown)?),
Config::LogrotateFs(c) => {
Self::LogrotateFs(logrotate_fs::Server::new(general, c, shutdown)?)
}
};
Ok(srv)
}
Expand All @@ -98,6 +108,7 @@ impl FileGen {
match self {
Self::Traditional(inner) => inner.spin().await?,
Self::Logrotate(inner) => inner.spin().await?,
Self::LogrotateFs(inner) => inner.spin().await?,
};

Ok(())
Expand Down
Loading

0 comments on commit 677d49a

Please sign in to comment.