Skip to content
Open
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: 15 additions & 0 deletions .changeset/shared_utilities_to_handle_vrl_expressions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
default: minor
---

# Breaking

Removed `pool_idle_timeout_seconds` from `traffic_shaping`, instead use `pool_idle_timeout` with duration format.

```diff
traffic_shaping:
- pool_idle_timeout_seconds: 30
+ pool_idle_timeout: 30s
```

#540 by @ardatan
1 change: 1 addition & 0 deletions Cargo.lock

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

29 changes: 12 additions & 17 deletions bin/router/src/pipeline/progressive_override.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use std::collections::{BTreeMap, HashMap, HashSet};

use hive_router_config::override_labels::{LabelOverrideValue, OverrideLabelsConfig};
use hive_router_plan_executor::execution::client_request_details::ClientRequestDetails;
use hive_router_plan_executor::{
execution::client_request_details::ClientRequestDetails, utils::expression::compile_expression,
};
use hive_router_query_planner::{
graph::{PlannerOverrideContext, PERCENTAGE_SCALE_FACTOR},
state::supergraph_state::SupergraphState,
};
use rand::Rng;
use vrl::{
compiler::{compile as vrl_compile, Program as VrlProgram, TargetValue as VrlTargetValue},
compiler::Program as VrlProgram,
compiler::TargetValue as VrlTargetValue,
core::Value as VrlValue,
prelude::{
state::RuntimeState as VrlState, Context as VrlContext, ExpressionError,
TimeZone as VrlTimeZone,
},
stdlib::all as vrl_build_functions,
value::Secrets as VrlSecrets,
};

Expand Down Expand Up @@ -126,27 +128,20 @@ impl OverrideLabelsEvaluator {
) -> Result<Self, OverrideLabelsCompileError> {
let mut static_enabled_labels = HashSet::new();
let mut expressions = HashMap::new();
let vrl_functions = vrl_build_functions();

for (label, value) in override_labels_config.iter() {
match value {
LabelOverrideValue::Boolean(true) => {
static_enabled_labels.insert(label.clone());
}
LabelOverrideValue::Expression { expression } => {
let compilation_result =
vrl_compile(expression, &vrl_functions).map_err(|diagnostics| {
OverrideLabelsCompileError {
label: label.clone(),
error: diagnostics
.errors()
.into_iter()
.map(|d| d.code.to_string() + ": " + &d.message)
.collect::<Vec<_>>()
.join(", "),
}
})?;
expressions.insert(label.clone(), compilation_result.program);
let program = compile_expression(expression, None).map_err(|err| {
OverrideLabelsCompileError {
label: label.clone(),
error: err.to_string(),
}
})?;
expressions.insert(label.clone(), program);
}
_ => {} // Skip false booleans
}
Expand Down
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
|[**override\_subgraph\_urls**](#override_subgraph_urls)|`object`|Configuration for overriding subgraph URLs.<br/>Default: `{}`<br/>||
|[**query\_planner**](#query_planner)|`object`|Query planning configuration.<br/>Default: `{"allow_expose":false,"timeout":"10s"}`<br/>||
|[**supergraph**](#supergraph)|`object`|Configuration for the Federation supergraph source. By default, the router will use a local file-based supergraph source (`./supergraph.graphql`).<br/>||
|[**traffic\_shaping**](#traffic_shaping)|`object`|Configuration for the traffic-shaper executor. Use these configurations to control how requests are being executed to subgraphs.<br/>Default: `{"dedupe_enabled":true,"max_connections_per_host":100,"pool_idle_timeout_seconds":50}`<br/>||
|[**traffic\_shaping**](#traffic_shaping)|`object`|Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.<br/>Default: `{"dedupe_enabled":true,"max_connections_per_host":100,"pool_idle_timeout":"50s"}`<br/>||

**Additional Properties:** not allowed
**Example**
Expand Down Expand Up @@ -109,7 +109,7 @@ supergraph: {}
traffic_shaping:
dedupe_enabled: true
max_connections_per_host: 100
pool_idle_timeout_seconds: 50
pool_idle_timeout: 50s

```

Expand Down Expand Up @@ -1808,7 +1808,7 @@ Request timeout for the Hive Console CDN requests.
<a name="traffic_shaping"></a>
## traffic\_shaping: object

Configuration for the traffic-shaper executor. Use these configurations to control how requests are being executed to subgraphs.
Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.


**Properties**
Expand All @@ -1817,15 +1817,15 @@ Configuration for the traffic-shaper executor. Use these configurations to contr
|----|----|-----------|--------|
|**dedupe\_enabled**|`boolean`|Enables/disables request deduplication to subgraphs.<br/><br/>When requests exactly matches the hashing mechanism (e.g., subgraph name, URL, headers, query, variables), and are executed at the same time, they will<br/>be deduplicated by sharing the response of other in-flight requests.<br/>Default: `true`<br/>||
|**max\_connections\_per\_host**|`integer`|Limits the concurrent amount of requests/connections per host/subgraph.<br/>Default: `100`<br/>Format: `"uint"`<br/>Minimum: `0`<br/>||
|**pool\_idle\_timeout\_seconds**|`integer`|Timeout for idle sockets being kept-alive.<br/>Default: `50`<br/>Format: `"uint64"`<br/>Minimum: `0`<br/>||
|**pool\_idle\_timeout**|`string`|Timeout for idle sockets being kept-alive.<br/>Default: `"50s"`<br/>||

**Additional Properties:** not allowed
**Example**

```yaml
dedupe_enabled: true
max_connections_per_host: 100
pool_idle_timeout_seconds: 50
pool_idle_timeout: 50s

```

Expand Down
1 change: 1 addition & 0 deletions lib/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ itoa = "1.0.15"
ryu = "1.0.20"
indexmap = "2.10.0"
bumpalo = "3.19.0"
once_cell = "1.21.3"

[dev-dependencies]
subgraphs = { path = "../../bench/subgraphs" }
Expand Down
17 changes: 1 addition & 16 deletions lib/executor/src/executors/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vrl::{diagnostic::DiagnosticList, prelude::ExpressionError};
use vrl::prelude::ExpressionError;

use crate::response::graphql_error::{GraphQLError, GraphQLErrorExtensions};

Expand Down Expand Up @@ -34,21 +34,6 @@ impl From<SubgraphExecutorError> for GraphQLError {
}

impl SubgraphExecutorError {
pub fn new_endpoint_expression_build(
subgraph_name: String,
diagnostics: DiagnosticList,
) -> Self {
SubgraphExecutorError::EndpointExpressionBuild(
subgraph_name,
diagnostics
.errors()
.into_iter()
.map(|d| d.code.to_string() + ": " + &d.message)
.collect::<Vec<_>>()
.join(", "),
)
}

pub fn new_endpoint_expression_resolution_failure(
subgraph_name: String,
error: ExpressionError,
Expand Down
Loading
Loading