pub struct ShardRouter { /* private fields */ }Expand description
샤드 라우터
키를 받아 어느 ShardNode로 라우팅할지 결정합니다. 일관된 해싱(Consistent Hashing) 링을 통해 노드 간 부하 분산을 수행합니다.
Implementations§
Source§impl ShardRouter
impl ShardRouter
Sourcepub fn new_with_addresses(addresses: Vec<String>) -> Self
pub fn new_with_addresses(addresses: Vec<String>) -> Self
노드 주소 목록으로 라우터 생성
Sourcepub fn num_shards(&self) -> usize
pub fn num_shards(&self) -> usize
샤드 수
Sourcepub fn shard_index(&self, key: &[u8]) -> usize
pub fn shard_index(&self, key: &[u8]) -> usize
key 바이트로부터 물리 샤드 노드 ID 인덱스 결정 (Consistent Hashing)
Sourcepub fn all_shards(&self) -> &[ShardNode]
pub fn all_shards(&self) -> &[ShardNode]
모든 샤드 목록 반환 (scatter-gather broadcast 용)
Sourcepub fn sub_table_name(&self, base_table: &str, key: &[u8]) -> String
pub fn sub_table_name(&self, base_table: &str, key: &[u8]) -> String
sub-table 이름 생성: {base_table}__shard_{idx}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShardRouter
impl RefUnwindSafe for ShardRouter
impl Send for ShardRouter
impl Sync for ShardRouter
impl Unpin for ShardRouter
impl UnsafeUnpin for ShardRouter
impl UnwindSafe for ShardRouter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§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