Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce 'logrotate' log generator #720

Merged
merged 5 commits into from
Nov 7, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.20.0-rc1]
### Added
- A new 'logrotate' file generator is introduced.

### Changed
- Existing file generator is renamed 'traditional', requiring a configuration
change.
Expand Down
10 changes: 10 additions & 0 deletions lading/src/generator/file_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! Additional metrics may be emitted by this generator's [throttle].
//!

pub mod logrotate;
pub mod traditional;

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

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

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

impl FileGen {
Expand All @@ -65,6 +73,7 @@ impl FileGen {
Config::Traditional(c) => {
Self::Traditional(traditional::Server::new(general, c, shutdown)?)
}
Config::Logrotate(c) => Self::Logrotate(logrotate::Server::new(general, c, shutdown)?),
};
Ok(srv)
}
Expand All @@ -84,6 +93,7 @@ impl FileGen {
pub async fn spin(self) -> Result<(), Error> {
match self {
Self::Traditional(inner) => inner.spin().await?,
Self::Logrotate(inner) => inner.spin().await?,
};

Ok(())
Expand Down
Loading
Loading