pub struct RequestRouter { /* private fields */ }Expand description
Request Router for partition-aware request routing
Implementations§
Source§impl RequestRouter
impl RequestRouter
Sourcepub fn new(registry: Arc<NodeRegistry>) -> Self
pub fn new(registry: Arc<NodeRegistry>) -> Self
Sourcepub fn route_for_entity(&self, entity_id: &EntityId) -> Result<Node>
pub fn route_for_entity(&self, entity_id: &EntityId) -> Result<Node>
Sourcepub fn route_for_partition(&self, partition_key: &PartitionKey) -> Result<Node>
pub fn route_for_partition(&self, partition_key: &PartitionKey) -> Result<Node>
Sourcepub fn nodes_for_read(&self) -> Vec<Node>
pub fn nodes_for_read(&self) -> Vec<Node>
Get all nodes for load-balanced read operations
Returns all healthy nodes that can serve read requests. Useful for fan-out queries across multiple nodes.
Sourcepub fn can_node_handle_entity(&self, entity_id: &EntityId, node_id: u32) -> bool
pub fn can_node_handle_entity(&self, entity_id: &EntityId, node_id: u32) -> bool
Check if a specific node can handle the entity
Useful for sticky sessions or connection pooling.
Sourcepub fn partition_distribution(&self) -> HashMap<u32, Vec<u32>>
pub fn partition_distribution(&self) -> HashMap<u32, Vec<u32>>
Get partition distribution for monitoring
Returns map of node_id -> partition_ids for observability.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check if routing is available
Returns true if cluster is healthy and can handle requests.
Auto Trait Implementations§
impl Freeze for RequestRouter
impl !RefUnwindSafe for RequestRouter
impl Send for RequestRouter
impl Sync for RequestRouter
impl Unpin for RequestRouter
impl !UnwindSafe for RequestRouter
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more