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

Fix Admin Config model and documentation #218

Merged
merged 2 commits into from
Mar 22, 2021
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
15 changes: 5 additions & 10 deletions docs/proxy-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ properties:
admin:
type: object
description: |
Configuration of operational proxy behavior.
Configuration of proxy admin HTTP interface.
properties:
metrics:
type: object
address:
type: string
description: |
Metrics related configuration.
properties:
port:
type: integer
description: |
Port on which to expose metrics.
default: 9091
Socket Address and port to bind the administration interface to.
default: [::]:9091
static:
type: object
description: |
Expand Down
6 changes: 4 additions & 2 deletions src/config/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
*/

use super::{Config, Filter};
use crate::config::{EndPoint, Proxy, Source, Version};
use crate::config::{Admin, EndPoint, Proxy, Source, Version};

/// Builder for a [`Config`]
#[derive(Debug)]
pub struct Builder {
pub port: u16,
pub source: Source,
pub admin: Admin,
}

impl Builder {
/// Returns a [`Builder`] with empty values.
pub fn empty() -> Self {
Builder {
port: 0,
admin: Admin::default(),
source: Source::Static {
filters: vec![],
endpoints: vec![],
Expand All @@ -52,7 +54,7 @@ impl Builder {
id: "test".into(),
port: self.port,
},
admin: None,
admin: self.admin,
source: self.source,
phantom: None,
}
Expand Down
16 changes: 10 additions & 6 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ impl Default for Proxy {
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdminAddress {
port: u16,
pub struct Admin {
pub address: SocketAddr,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Admin {
address: Option<AdminAddress>,
impl Default for Admin {
fn default() -> Self {
Admin {
address: "[::]:9091".parse().unwrap(),
}
}
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
Expand Down Expand Up @@ -106,7 +109,8 @@ pub struct Config {
#[serde(default)]
pub proxy: Proxy,

pub admin: Option<Admin>,
#[serde(default)]
pub admin: Admin,

#[serde(flatten)]
pub source: Source,
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(super) enum ValidatedSource {
pub(super) struct ValidatedConfig {
pub version: Version,
pub proxy: Proxy,
pub admin: Option<Admin>,
pub admin: Admin,
pub source: ValidatedSource,
// Limit struct creation to the builder.
pub phantom: PhantomData<()>,
Expand Down