#![cfg(feature = "awscout")]
#![cfg_attr(docsrs, doc(cfg(feature = "awscout")))]
use crate::{Concurrency, DirectLogger, Logger, QueuedLogger, service};
pub struct CloudWatch {}
impl CloudWatch {
pub fn cout(self) -> CloudWatchCout {
CloudWatchCout::default()
}
}
pub struct CloudWatchCout {
max_retries: usize,
worker_count: usize,
}
impl CloudWatchCout {
pub fn new(max_retries: usize, worker_count: usize) -> Self {
Self {
max_retries,
worker_count,
}
}
pub fn get_worker_count(&self) -> usize {
self.worker_count
}
pub fn get_max_retries(&self) -> usize {
self.max_retries
}
pub fn worker_count(self, worker_count: usize) -> CloudWatchCout {
CloudWatchCout {
worker_count,
..self
}
}
pub fn max_retries(self, max_retries: usize) -> CloudWatchCout {
CloudWatchCout {
max_retries,
..self
}
}
pub fn build(self, concurrency: Concurrency) -> Logger {
match concurrency {
Concurrency::Sync => self.build_direct(),
Concurrency::Async => self.build_queued(),
}
}
pub fn build_direct(self) -> Logger {
Logger::new(self.build_impl_direct())
}
pub fn build_queued(self) -> Logger {
Logger::new(self.build_impl_queued())
}
pub fn build_impl_direct(self) -> Box<DirectLogger> {
DirectLogger::new(service::CloudWatchCout::new(), self.max_retries)
}
pub fn build_impl_queued(self) -> Box<QueuedLogger> {
QueuedLogger::new(
service::CloudWatchCout::new(),
self.max_retries,
self.worker_count,
)
}
}
impl Default for CloudWatchCout {
fn default() -> Self {
CloudWatchCout {
worker_count: 1,
max_retries: 3,
}
}
}