Skip to content

Commit

Permalink
refactor: adjust pingap core
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Feb 10, 2025
1 parent a788778 commit ce2c262
Show file tree
Hide file tree
Showing 51 changed files with 360 additions and 330 deletions.
62 changes: 30 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ uuid = { version = "1.12.1", features = [
"std",
"fast-rng",
], default-features = false }
pingap-core = { path = "pingap-core" }
pingap-util = { path = "pingap-util" }
pingap-limit = { path = "pingap-limit" }
pingap-webhook = { path = "pingap-webhook" }
Expand All @@ -79,7 +80,6 @@ pingap-config = { path = "pingap-config" }
pingap-cache = { path = "pingap-cache" }
pingap-upstream = { path = "pingap-upstream" }
pingap-certificate = { path = "pingap-certificate" }
pingap-http-extra = { path = "pingap-http-extra" }
pingap-location = { path = "pingap-location" }
pingap-state = { path = "pingap-state" }
pingap-performance = { path = "pingap-performance" }
Expand All @@ -99,7 +99,7 @@ full = [
"opentelemetry-http",
"pingora/sentry",
"pingap-cache/full",
"pingap-state/full",
"pingap-core/full",
"pingap-performance/full",
"pingap-otel",
"pingap-sentry",
Expand Down Expand Up @@ -144,7 +144,6 @@ members = [
"pingap-cache",
"pingap-upstream",
"pingap-certificate",
"pingap-http-extra",
"pingap-location",
"pingap-state",
"pingap-performance",
Expand All @@ -154,6 +153,7 @@ members = [
"pingap-pyroscope",
"pingap-acme",
"pingap-plugin",
"pingap-core",
]

[workspace.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use criterion::{criterion_group, criterion_main, Criterion};
use http::{HeaderName, HeaderValue, StatusCode};
use nanoid::nanoid;
use pingap_config::LocationConf;
use pingap_http_extra::{convert_headers, HttpResponse};
use pingap_core::{CompressionStat, Ctx};
use pingap_core::{convert_headers, HttpResponse};
use pingap_location::Location;
use pingap_logger::Parser;
use pingap_state::{CompressionStat, Ctx};
use pingap_util::get_super_ts;
use pingora::http::{RequestHeader, ResponseHeader};
use pingora::proxy::Session;
Expand Down
20 changes: 9 additions & 11 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
graph TD
acme --> certificate
acme --> config
acme --> http-extra
acme --> core
acme --> service
acme --> state
acme --> util
acme --> webhook
Expand All @@ -19,6 +18,7 @@ graph TD
certificate --> util
certificate --> webhook
config --> core
config --> discovery
config --> util
Expand All @@ -28,34 +28,32 @@ graph TD
health --> util
health --> webhook
http-extra --> util
limit --> util
location --> config
location --> http-extra
location --> core
location --> util
logger --> config
logger --> location
logger --> core
logger --> service
logger --> state
logger --> util
performance --> cache
performance --> config
performance --> core
performance --> location
performance --> service
performance --> state
performance --> upstream
performance --> util
plugin --> cache
plugin --> config
plugin --> http-extra
plugin --> core
plugin --> state
plugin --> util
state --> core
upstream --> config
upstream --> discovery
upstream --> health
Expand All @@ -68,9 +66,9 @@ graph TD
pingap --> cache
pingap --> certificate
pingap --> config
pingap --> core
pingap --> discovery
pingap --> health
pingap --> http-extra
pingap --> limit
pingap --> location
pingap --> logger
Expand Down
3 changes: 1 addition & 2 deletions pingap-acme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ pingap-certificate = { path = "../pingap-certificate" }
pingap-config = { path = "../pingap-config" }
pingap-service = { path = "../pingap-service" }
pingap-util = { path = "../pingap-util" }
pingap-state = { path = "../pingap-state" }
pingap-http-extra = { path = "../pingap-http-extra" }
pingap-webhook = { path = "../pingap-webhook" }
pingap-core = { path = "../pingap-core" }


[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions pingap-acme/src/lets_encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use pingap_config::{
get_current_config, set_current_config, ConfigStorage, LoadConfigOptions,
PingapConf, CATEGORY_CERTIFICATE,
};
use pingap_http_extra::HttpResponse;
use pingap_core::HttpResponse;
use pingap_service::Error as ServiceError;
use pingap_service::SimpleServiceTaskFuture;
use pingap_state::Ctx;
use pingap_core::Ctx;
use pingora::proxy::Session;
use std::time::Duration;
use substring::Substring;
Expand Down
1 change: 1 addition & 0 deletions pingap-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ snafu = { workspace = true }
base64 = { workspace = true }
pingap-discovery = { path = "../pingap-discovery" }
pingap-util = { path = "../pingap-util" }
pingap-core = { path = "../pingap-core" }


[package.metadata.cargo-machete]
Expand Down
37 changes: 2 additions & 35 deletions pingap-config/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,40 +114,6 @@ impl<'de> Deserialize<'de> for PluginCategory {
}
}

#[derive(
PartialEq, Debug, Default, Clone, Copy, EnumString, strum::Display,
)]
#[strum(serialize_all = "snake_case")]
pub enum PluginStep {
EarlyRequest,
#[default]
Request,
ProxyUpstream,
Response,
}

impl Serialize for PluginStep {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}

impl<'de> Deserialize<'de> for PluginStep {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value: String = serde::Deserialize::deserialize(deserializer)?;
let category =
PluginStep::from_str(&value).unwrap_or(PluginStep::default());

Ok(category)
}
}

/// Configuration struct for TLS/SSL certificates
#[derive(Debug, Default, Deserialize, Clone, Serialize, Hash)]
pub struct CertificateConf {
Expand Down Expand Up @@ -1301,11 +1267,12 @@ pub fn get_config_hash() -> String {
mod tests {
use super::{
get_config_hash, set_current_config, validate_cert, BasicConf,
CertificateConf, PluginStep,
CertificateConf,
};
use super::{
LocationConf, PingapConf, PluginCategory, ServerConf, UpstreamConf,
};
use pingap_core::PluginStep;
use pingap_util::base64_encode;
use pretty_assertions::assert_eq;
use serde::{Deserialize, Serialize};
Expand Down
21 changes: 13 additions & 8 deletions pingap-http-extra/Cargo.toml → pingap-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
[package]
name = "pingap-http-extra"
name = "pingap-core"
version = "0.9.10"
edition = "2021"
authors = ["Tree Xie <[email protected]>"]
license = "Apache-2.0"
homepage = "https://github.com/vicanso/pingap"
repository = "https://github.com/vicanso/pingap"
keywords = ["pingap", "http", "extra"]
keywords = ["pingap", "core"]

[lib]
name = "pingap_http_extra"
path = "src/lib.rs"

[dependencies]
ahash = { workspace = true }
bytes = { workspace = true }
http = { workspace = true }
pingora = { workspace = true }
pingora-limits = { workspace = true }
itoa = { workspace = true }
snafu = { workspace = true }
async-trait = { workspace = true }
once_cell = { workspace = true }
strum = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
serde_json = { workspace = true }
opentelemetry = { version = "0.27.1", default-features = false, features = [
"trace",
], optional = true }

pingap-util = { path = "../pingap-util" }

[features]
full = ["opentelemetry"]

[dev-dependencies]
pretty_assertions = "1.4.0"
tokio-test = "0.4.4"
nanoid = "0.4.0"
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ce2c262

Please sign in to comment.