@@ -3,8 +3,8 @@ use std::sync::Arc;
33
44use crate :: executors:: common:: HttpExecutionResponse ;
55use crate :: executors:: dedupe:: { request_fingerprint, ABuildHasher , SharedResponse } ;
6+ use crate :: utils:: expression:: execute_expression_with_value;
67use dashmap:: DashMap ;
7- use hive_router_config:: hmac_signature:: BooleanOrExpression ;
88use hive_router_config:: HiveRouterConfig ;
99use tokio:: sync:: OnceCell ;
1010
@@ -22,6 +22,7 @@ use hyper_util::client::legacy::{connect::HttpConnector, Client};
2222use sha2:: Sha256 ;
2323use tokio:: sync:: Semaphore ;
2424use tracing:: debug;
25+ use vrl:: compiler:: Program as VrlProgram ;
2526
2627use crate :: executors:: common:: HttpExecutionRequest ;
2728use crate :: executors:: error:: SubgraphExecutorError ;
@@ -42,6 +43,7 @@ pub struct HTTPSubgraphExecutor {
4243 pub semaphore : Arc < Semaphore > ,
4344 pub config : Arc < HiveRouterConfig > ,
4445 pub in_flight_requests : Arc < DashMap < u64 , Arc < OnceCell < SharedResponse > > , ABuildHasher > > ,
46+ pub should_sign_hmac : BooleanOrProgram ,
4547}
4648
4749const FIRST_VARIABLE_STR : & [ u8 ] = b",\" variables\" :{" ;
@@ -52,6 +54,12 @@ pub type HttpClient = Client<HttpsConnector<HttpConnector>, Full<Bytes>>;
5254
5355type HmacSha256 = Hmac < Sha256 > ;
5456
57+ #[ derive( Debug ) ]
58+ pub enum BooleanOrProgram {
59+ Boolean ( bool ) ,
60+ Program ( Box < VrlProgram > ) ,
61+ }
62+
5563impl HTTPSubgraphExecutor {
5664 pub fn new (
5765 subgraph_name : String ,
@@ -60,6 +68,7 @@ impl HTTPSubgraphExecutor {
6068 semaphore : Arc < Semaphore > ,
6169 config : Arc < HiveRouterConfig > ,
6270 in_flight_requests : Arc < DashMap < u64 , Arc < OnceCell < SharedResponse > > , ABuildHasher > > ,
71+ should_sign_hmac : BooleanOrProgram ,
6372 ) -> Self {
6473 let mut header_map = HeaderMap :: new ( ) ;
6574 header_map. insert (
@@ -79,6 +88,7 @@ impl HTTPSubgraphExecutor {
7988 semaphore,
8089 config,
8190 in_flight_requests,
91+ should_sign_hmac,
8292 }
8393 }
8494
@@ -126,9 +136,9 @@ impl HTTPSubgraphExecutor {
126136 body. put ( CLOSE_BRACE ) ;
127137 }
128138
129- let should_sign_hmac = match & self . config . hmac_signature . enabled {
130- BooleanOrExpression :: Boolean ( b) => * b,
131- BooleanOrExpression :: Expression ( expr) => {
139+ let should_sign_hmac = match & self . should_sign_hmac {
140+ BooleanOrProgram :: Boolean ( b) => * b,
141+ BooleanOrProgram :: Program ( expr) => {
132142 // .subgraph
133143 let subgraph_value = VrlValue :: Object ( BTreeMap :: from ( [ (
134144 "name" . into ( ) ,
@@ -140,7 +150,7 @@ impl HTTPSubgraphExecutor {
140150 ( "subgraph" . into ( ) , subgraph_value) ,
141151 ( "request" . into ( ) , request_value) ,
142152 ] ) ) ;
143- let result = expr . execute_with_value ( target_value) ;
153+ let result = execute_expression_with_value ( expr , target_value) ;
144154 match result {
145155 Ok ( VrlValue :: Boolean ( b) ) => b,
146156 Ok ( _) => {
0 commit comments