use ff_core::keys::{ExecKeyContext, IndexKeys};
use ff_core::partition::{
Partition, PartitionConfig, PartitionFamily, execution_partition,
};
use ff_core::types::ExecutionId;
pub struct PartitionRouter {
config: PartitionConfig,
}
impl PartitionRouter {
pub fn new(config: PartitionConfig) -> Self {
Self { config }
}
pub fn partition_for(&self, eid: &ExecutionId) -> Partition {
execution_partition(eid, &self.config)
}
pub fn exec_keys(&self, eid: &ExecutionId) -> ExecKeyContext {
let partition = self.partition_for(eid);
ExecKeyContext::new(&partition, eid)
}
pub fn index_keys(&self, partition_index: u16) -> IndexKeys {
let partition = Partition {
family: PartitionFamily::Execution,
index: partition_index,
};
IndexKeys::new(&partition)
}
pub fn config(&self) -> &PartitionConfig {
&self.config
}
pub fn num_flow_partitions(&self) -> u16 {
self.config.num_flow_partitions
}
}