add more trait for peer (#222)
This commit is contained in:
@@ -17,6 +17,7 @@ tonic::include_proto!("greptime.v1.meta");
|
|||||||
mod mailbox;
|
mod mailbox;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
pub const PROTOCOL_VERSION: u64 = 1;
|
pub const PROTOCOL_VERSION: u64 = 1;
|
||||||
@@ -57,6 +58,27 @@ impl Hash for Peer {
|
|||||||
|
|
||||||
impl Eq for Peer {}
|
impl Eq for Peer {}
|
||||||
|
|
||||||
|
impl Display for Peer {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "peer-{}({})", self.id, self.addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Peer {
|
||||||
|
pub fn new(id: u64, addr: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
addr: addr.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn empty(id: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
addr: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl RequestHeader {
|
impl RequestHeader {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(member_id: u64, role: Role, tracing_context: HashMap<String, String>) -> Self {
|
pub fn new(member_id: u64, role: Role, tracing_context: HashMap<String, String>) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user