feat: Update NginxConfigProvider to return Result with ServiceError for upstream and upstream target
This commit is contained in:
@@ -6,6 +6,7 @@ use uuid::Uuid;
|
||||
use database::generated::entities::{upstream, upstream_target};
|
||||
|
||||
use crate::{
|
||||
errors::service_error::ServiceError,
|
||||
services::nginx::{builder::NginxConfigProvider, traits::indentable::Indentable},
|
||||
set_if_some,
|
||||
};
|
||||
@@ -128,8 +129,8 @@ impl From<UpstreamTargetCreateInfo> for upstream_target::ActiveModel {
|
||||
}
|
||||
|
||||
impl NginxConfigProvider for UpstreamTargetInfo {
|
||||
fn to_nginx_config(&self, indent: Option<usize>) -> String {
|
||||
format!(
|
||||
fn to_nginx_config(&self, indent: Option<usize>) -> Result<String, ServiceError> {
|
||||
Ok(format!(
|
||||
"server {}:{} weight={}{}{};",
|
||||
self.target_host,
|
||||
self.target_port,
|
||||
@@ -137,7 +138,7 @@ impl NginxConfigProvider for UpstreamTargetInfo {
|
||||
if self.is_backup { " backup" } else { "" },
|
||||
if !self.enabled { " down" } else { "" },
|
||||
)
|
||||
.indent(indent.unwrap_or(0))
|
||||
.indent(indent.unwrap_or(0)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user