hive_router_plan_executor/executors/
common.rs

1use std::{collections::HashMap, sync::Arc};
2
3use async_trait::async_trait;
4use bytes::Bytes;
5
6#[async_trait]
7pub trait SubgraphExecutor {
8    async fn execute<'a>(&self, execution_request: HttpExecutionRequest<'a>) -> Bytes;
9    fn to_boxed_arc<'a>(self) -> Arc<Box<dyn SubgraphExecutor + Send + Sync + 'a>>
10    where
11        Self: Sized + Send + Sync + 'a,
12    {
13        Arc::new(Box::new(self))
14    }
15}
16
17pub type SubgraphExecutorType = dyn crate::executors::common::SubgraphExecutor + Send + Sync;
18
19pub type SubgraphExecutorBoxedArc = Arc<Box<SubgraphExecutorType>>;
20
21pub struct HttpExecutionRequest<'a> {
22    pub query: &'a str,
23    pub dedupe: bool,
24    pub operation_name: Option<&'a str>,
25    // TODO: variables could be stringified before even executing the request
26    pub variables: Option<HashMap<&'a str, &'a sonic_rs::Value>>,
27    pub representations: Option<Vec<u8>>,
28}