feat: implement transaction handling for upstream and target operations
- Added transaction support in `add_upstream_target`, `remove_upstream`, `remove_upstream_target`, `update_upstream`, and `update_upstream_target` functions to ensure atomicity of operations. - Updated the `NginxService` to include methods for validating and applying configurations using the agent service. - Enhanced error handling in agent service interactions, returning appropriate internal server errors when agent communication fails. - Introduced mock agent service for testing, allowing for simulation of agent interactions without actual network calls. - Refactored tests to cover scenarios where agent operations fail, ensuring that internal server errors are returned as expected.
This commit is contained in:
@@ -6,17 +6,12 @@ pub trait NginxConfigProvider {
|
||||
fn to_nginx_config(&self, indent: Option<usize>) -> String;
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NginxConfigBuilder {
|
||||
upstreams: Vec<UpstreamInfo>,
|
||||
}
|
||||
|
||||
impl NginxConfigBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
upstreams: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_upstream(&mut self, upstream: UpstreamInfo) {
|
||||
self.upstreams.push(upstream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user