chore: subdivision of different channels (#6526)

* chore: subdivision of different channels

* chore: add as_str for channel

* chore: fix by pr comment

* chore: fix by pr comment
This commit is contained in:
localhost
2025-07-15 17:22:01 +08:00
committed by GitHub
parent 9442284fd4
commit 9d05c7c5fa
4 changed files with 34 additions and 22 deletions

View File

@@ -178,7 +178,7 @@ pub async fn query_pipeline(
let version = to_pipeline_version(query_params.version.as_deref()).context(PipelineSnafu)?;
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
let (pipeline, pipeline_version) = handler
@@ -223,7 +223,7 @@ pub async fn add_pipeline(
}
);
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
let content_type = "yaml";
@@ -268,7 +268,7 @@ pub async fn delete_pipeline(
let version = to_pipeline_version(Some(&version_str)).context(PipelineSnafu)?;
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
handler
@@ -519,7 +519,7 @@ pub async fn pipeline_dryrun(
) -> Result<Response> {
let handler = log_state.log_handler;
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
match check_pipeline_dryrun_params_valid(&payload) {
@@ -644,7 +644,7 @@ pub async fn log_ingester(
let value = extract_pipeline_value_by_content_type(content_type, payload, ignore_errors)?;
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
let value = log_state

View File

@@ -91,7 +91,7 @@ pub async fn sql(
}
let db = query_ctx.get_db_string();
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::HttpSql);
let query_ctx = Arc::new(query_ctx);
let _timer = crate::metrics::METRIC_HTTP_SQL_ELAPSED
@@ -298,7 +298,7 @@ pub async fn promql(
let exec_start = Instant::now();
let db = query_ctx.get_db_string();
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Promql);
let query_ctx = Arc::new(query_ctx);
let _timer = crate::metrics::METRIC_HTTP_PROMQL_ELAPSED

View File

@@ -35,7 +35,7 @@ pub async fn logs(
let exec_start = Instant::now();
let db = query_ctx.get_db_string();
query_ctx.set_channel(Channel::Http);
query_ctx.set_channel(Channel::Log);
let query_ctx = Arc::new(query_ctx);
let _timer = crate::metrics::METRIC_HTTP_LOGS_ELAPSED

View File

@@ -518,7 +518,7 @@ pub enum Channel {
Mysql = 1,
Postgres = 2,
Http = 3,
HttpSql = 3,
Prometheus = 4,
Otlp = 5,
Grpc = 6,
@@ -527,6 +527,8 @@ pub enum Channel {
Loki = 9,
Elasticsearch = 10,
Jaeger = 11,
Log = 12,
Promql = 13,
}
impl From<u32> for Channel {
@@ -534,7 +536,7 @@ impl From<u32> for Channel {
match value {
1 => Self::Mysql,
2 => Self::Postgres,
3 => Self::Http,
3 => Self::HttpSql,
4 => Self::Prometheus,
5 => Self::Otlp,
6 => Self::Grpc,
@@ -543,6 +545,8 @@ impl From<u32> for Channel {
9 => Self::Loki,
10 => Self::Elasticsearch,
11 => Self::Jaeger,
12 => Self::Log,
13 => Self::Promql,
_ => Self::Unknown,
}
}
@@ -560,19 +564,27 @@ impl Channel {
impl Display for Channel {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}", self.as_ref())
}
}
impl AsRef<str> for Channel {
fn as_ref(&self) -> &str {
match self {
Channel::Mysql => write!(f, "mysql"),
Channel::Postgres => write!(f, "postgres"),
Channel::Http => write!(f, "http"),
Channel::Prometheus => write!(f, "prometheus"),
Channel::Otlp => write!(f, "otlp"),
Channel::Grpc => write!(f, "grpc"),
Channel::Influx => write!(f, "influx"),
Channel::Opentsdb => write!(f, "opentsdb"),
Channel::Loki => write!(f, "loki"),
Channel::Elasticsearch => write!(f, "elasticsearch"),
Channel::Jaeger => write!(f, "jaeger"),
Channel::Unknown => write!(f, "unknown"),
Channel::Mysql => "mysql",
Channel::Postgres => "postgres",
Channel::HttpSql => "httpsql",
Channel::Prometheus => "prometheus",
Channel::Otlp => "otlp",
Channel::Grpc => "grpc",
Channel::Influx => "influx",
Channel::Opentsdb => "opentsdb",
Channel::Loki => "loki",
Channel::Elasticsearch => "elasticsearch",
Channel::Jaeger => "jaeger",
Channel::Log => "log",
Channel::Promql => "promql",
Channel::Unknown => "unknown",
}
}
}